Skip to content

MasterDetailLayoutLocator can't press Esc on the detail or click the backdrop #306

Open

Description

@peholmst

Summary

When a MasterDetailLayout shows its detail on top of the master (the overlay mode on a narrow screen), the user can close it by pressing Esc or by clicking the backdrop. Applications listen for this with addDetailEscapePressListener(...) and addBackdropClickListener(...), for example to deselect the row or to ask about unsaved changes first.

MasterDetailLayoutLocator/MasterDetailLayoutTester can't simulate either. They only have getMaster(), getDetail(), getDetailPlaceholder() and isDetailPlaceholderVisible(). Tests have to fire the events themselves:

var layout = window.findMasterDetailLayout().component();
ComponentUtil.fireEvent(layout, new MasterDetailLayout.DetailEscapePressEvent(layout, true));
ComponentUtil.fireEvent(layout, new MasterDetailLayout.BackdropClickEvent(layout, true));

Expected

MasterDetailLayoutLocator gets methods like pressEscapeOnDetail() and clickBackdrop(). They fire the events as coming from the client, and refuse when the detail isn't shown in a mode where the user could do that.

Versions

Vaadin 25.3.4, browserless-test 25.3.2, Java 25.

Activity

  1. totally-not-ai commented on Oct 31, 2026

    @totally-not-ai
    Contributor

    Thanks for the report. This is a valid gap: MasterDetailLayoutTester (and so the generated MasterDetailLayoutLocator) only exposes read accessors, and there is no way to simulate the two dismiss gestures the web component supports.

    Root cause: the web component dispatches detail-escape-press when Escape is pressed in the detail area (in any mode, as long as there is a detail), and backdrop-click when the backdrop is clicked in overlay mode. The Flow component maps these to DetailEscapePressEvent and BackdropClickEvent via @DomEvent, but the tester never fires them.

    Proposed solution (implemented in #310):

    • pressEscapeOnDetail() and clickBackdrop() on the tester, so they also land on the generated locator. They fire the DOM events through the element listener map, so applications get the events with isFromClient() == true, the same way the browser would deliver them.
    • Both throw IllegalStateException when the layout isn't usable (hidden, disabled, inert behind a modal, …) or when no detail content is set, since then there is no detail area or backdrop to interact with.

    One limit on "refuse unless the detail is in overlay mode": the browser decides on overlay mode from the space available (it sets the overlay attribute on the client), and that state is never sent to the server. The tester can't tell split mode from overlay mode, so clickBackdrop() only requires a detail to be set. Its Javadoc says this and points to setForceOverlay(true) for tests that want the overlay state to be explicit. A stricter alternative would refuse clickBackdrop() unless isForceOverlay() is true, but that would reject legitimate tests of the narrow-screen case where overlay mode comes from the viewport size. Happy to switch to that if maintainers prefer it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions