Skip to content

fix: track visual modality so dialogs are refreshed on hotswap - #25417

Merged
platosha merged 18 commits into
mainfrom
fix/hotswap-refresh-with-visual-modality
Oct 16, 2026
Merged

platosha merged 18 commits into
mainfrom
fix/hotswap-refresh-with-visual-modality

Conversation

@totally-not-ai

@totally-not-ai totally-not-ai Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Dialogs are visually modal by default since 25.0, but ModalityMode.VISUAL was mapped to setChildModeless, so a component with visual modality was not tracked on the server side at all.

Both code paths that deal with overlays attached to the UI instead of the route were guarded by UI.hasModalComponent(), so with an open dialog they became no-ops:

  • AbstractNavigationStateRenderer no longer detached the dialog on a route refresh, leaving it visible with outdated contents.
  • Hotswapper no longer requested a refresh of the whole route chain.

What changed

  • Components set to ModalityMode.VISUAL are now tracked in UIInternals without making the UI inert. The meaning of hasModalComponent() and the inert semantics are unchanged; the new hasModalityComponent() / getModalityComponents() cover both strict and visual modality, and both call sites take the new information into account.
  • All components with modality are kept in a single recency-ordered stack of (component, mode, detach registration) entries, replacing the previous strict-only modal component stack. The active modal component is the most recent STRICT entry, and the inert state of the UI and its children is updated in one place by comparing the active modal component before and after each modality change. A single stack keeps getModalityComponents() in the order the components were set and cannot report a component twice when it switches between modes.
  • The detach listener that stops tracking a component is registered once per component and kept in its stack entry, so repeatedly changing the modality of a component does not pile up listeners on its element; it is removed when the component is set modeless.
  • Calling setChildModal again on the already active modal component now moves it to the top of the stack (above any visually modal component set after it) instead of being a no-op.
  • UI.setChildComponentModal(Component, boolean) still maps false to MODELESS, which now also clears visual modality; its Javadoc points visually modal components to the ModalityMode overload. Dialog needs to report its actual mode through that overload for the fix to cover all paths (re-attach, setVisible, setModality on an open dialog, add-then-open) — companion change: fix: pass dialog modality mode to UI instead of a strict flag flow-components#10440.
  • cleanModalComponents() in AbstractNavigationStateRenderer now removes all components with modality on REFRESH_ROUTE, instead of draining only the strict-modal stack. Modeless components are left untouched.

Fixes #25415

API Changes

com.vaadin.flow.component.internal.UIInternals

// Added
public boolean hasModalityComponent() // true if a child component with STRICT or VISUAL modality is set; unlike hasModalComponent() it also counts components that only show a modality curtain
public List<Component> getModalityComponents() // child components with STRICT or VISUAL modality, most recently set first, never null
public void setChildModal(Component child, ModalityMode mode) // overload of setChildModal(Component) that sets any modality mode; VISUAL tracks the child as having modality without making the UI and its other components inert

Dialogs are visually modal by default since 25.0, and ModalityMode.VISUAL
was mapped to setChildModeless, so a component with visual modality was
not tracked on the server side at all.

Both the code paths that deal with overlays attached to the UI instead of
the route are guarded by UI.hasModalComponent(), so with an open dialog
they became no-ops: AbstractNavigationStateRenderer no longer detached the
dialog on a route refresh, leaving it visible with outdated contents, and
Hotswapper no longer requested a refresh of the whole route chain.

Components set to ModalityMode.VISUAL are now tracked in UIInternals
without making the UI inert, keeping the meaning of hasModalComponent()
and the inert semantics unchanged, and both call sites take the new
information into account.

Fixes #25415
Tracking strict and visual modality in two separate stacks made
getModalityComponents() report the components in the wrong order and, when
a component switched between the two modes, report it twice.

Components with modality are now kept in one stack, in the order they were
set, while the existing modal component stack keeps taking care of the
inert state only. Registration of the detach listener that stops tracking a
component is idempotent, so repeatedly applying the same modality to a
component does not pile up listeners on its element.
@github-actions github-actions Bot added the +0.0.1 label Sep 1, 2026
@sonarqubecloud

sonarqubecloud Bot commented Sep 1, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Test Results

 1 663 files  ± 0   1 748 suites  ±0   2h 9m 26s ⏱️ + 3m 41s
12 904 tests +10  12 832 ✅ +10  72 💤 ±0  0 ❌ ±0 
13 537 runs  +10  13 465 ✅ +10  72 💤 ±0  0 ❌ ±0 

Results for commit 7365358. ± Comparison against base commit 3f5b0b9.

♻️ This comment has been updated with latest results.

@platosha platosha left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All @since 25.3 tags are outdated, they should mention 25.4 now.

totally-not-ai Bot and others added 3 commits October 15, 2026 10:54
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Memory footprint

Compared with the base commit 3f5b0b9.

Scenario Metric Base Head Change
Empty UI Heap retained per UI 7,880 B 7,880 B no change
Empty UI Serialized session with one UI 21,870 B 21,864 B $\color{green}\textbf{−6 B}$ (−0.0%)
UI with 200 component rows Heap retained per UI 691,472 B 691,472 B no change
UI with 200 component rows Serialized session with one UI 438,487 B 438,481 B $\color{green}\textbf{−6 B}$ (−0.0%)
UI with 200 form rows added in the latest round trip Heap retained per UI 1,863,544 B 1,863,552 B $\color{red}\textbf{+8 B}$ (+0.0%)
UI with 200 form rows added in the latest round trip Serialized session with one UI 1,394,995 B 1,394,989 B $\color{green}\textbf{−6 B}$ (−0.0%)
UI with 200 form rows Heap retained per UI 1,818,592 B 1,818,592 B no change
UI with 200 form rows Serialized session with one UI 1,350,025 B 1,350,019 B $\color{green}\textbf{−6 B}$ (−0.0%)
UI with 200 form rows added in the latest round trip: Heap retained per UI by class
Class Instances Bytes
[B 0 +8
Scenarios
  • Empty UI (empty-ui): A UI with no components, which is the cost of every UI.
  • UI with 200 component rows (ui-with-200-component-rows): A UI with 200 rows, each a div with a class name and a style, holding a span, an input with a value change listener and a button with a click listener.
  • UI with 200 form rows added in the latest round trip (ui-with-200-form-rows-added-in-latest-round-trip): The UI with 200 form rows, with the rows added in the latest round trip, as when navigating to a view, so that the response kept for resending holds all of them.
  • UI with 200 form rows (ui-with-200-form-rows): A UI with 200 rows, each a layout with a theme and several styles, holding a text field and a combo box bound to a bean with a binder and a button with a click listener. The fields are web components with several properties and a synchronized value, and the combo box has client callable methods, as Vaadin components that load data do.

Measured by UIMemoryFootprintTest. The measurements are exact, so any difference comes from the change.

totally-not-ai Bot and others added 2 commits October 15, 2026 11:06
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@totally-not-ai

Copy link
Copy Markdown
Contributor Author

Fixed the three reported issues: UI.setChildComponentModal now uses an exhaustive switch over ModalityMode instead of the if/else chain, and the new visual-modal test in HotswapperTest uses a static import for verify.

@platosha

Copy link
Copy Markdown
Contributor

Could we implement this using a single modality related stack instead of two? Compare with the current approach.

totally-not-ai Bot and others added 2 commits October 15, 2026 12:15
Keep one recency ordered stack of components with their modality mode
and detach listener registration instead of a separate stack for strict
modal components, another for all components with modality and a map of
detach registrations. The active modal component is the most recent
strict entry, and the inert state is updated by comparing it before and
after each modality change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@totally-not-ai

Copy link
Copy Markdown
Contributor Author

@platosha Yes, done. UIInternals now keeps a single recency-ordered stack of (component, mode, detach registration) entries for every component with modality. Before this change there were three structures: the existing strict-only modalComponentStack, a second stack of all components with modality (strict and visual), and an identity map holding each component's detach-listener registration.

Comparison:

  • Two stacks (previous): the strict stack's top could be read directly, so getActiveModalComponent() was O(1). The cost was keeping the two stacks in sync on every transition (strict → visual, visual → strict, modeless, detach), plus the extra map to avoid stacking up detach listeners. Each inert transition had its own hand-written branch.
  • Single stack (now): one place records order and mode, so the stacks can't get out of sync. The active modal component is the most recent STRICT entry, found by a linear scan. That's negligible, since only a handful of dialogs are ever open. setChildModal, setChildVisuallyModal and setChildModeless all go through one setModality method. It compares the active modal component before and after the change and updates the inert/ignoreParentInert flags in one place. The detach registration lives in the stack entry, so it is reused when the mode changes and removed when the component becomes modeless.

Two small behaviour differences:

  • Calling setChildModal on the strict modal component that is already active now moves it above any visually modal component opened after it, so the order stays most-recent-first. Before, that call did nothing.
  • An explicit setChildModeless now also removes the detach listener. Before, the listener was left on the component until it was detached.

The public API is unchanged, and the existing modality, routing and hotswap tests pass.

@platosha

Copy link
Copy Markdown
Contributor

/code-review

@vaadin-review-bot vaadin-review-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the changes — left 2 comments.

Finding
📝 Public refreshCurrentRoute now detaches open dialogs, but its Javadoc says nothing about it
🧪 The inert assertion added to modalVisualComponent_addedAndRemoved_hasModalReturnsCorrectValue cannot fail

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Around line 1610 — could not attach to the exact diff line.

📝 Public refreshCurrentRoute now detaches open dialogs, but its Javadoc says nothing about it

cleanModalComponents now removes every component with modality on REFRESH_ROUTE, which includes VISUAL ones — i.e. dialogs in their default mode. refreshCurrentRoute(boolean) is public API usable in production, and its Javadoc only talks about re-instantiating the route target and chain.

The internal UIInternals.refreshCurrentRoute doc and the cleanModalComponents comment were both updated; the user-facing method that callers actually read was not.

UI.java:1610 · documentation

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the UI.refreshCurrentRoute(boolean) Javadoc: it now says that components with modality (open dialogs in either STRICT or VISUAL mode) are removed from the UI during the refresh, and that their presence makes the whole route chain refresh regardless of refreshRouteChain.

Replace the new setChildVisuallyModal method with an overload
setChildModal(Component, ModalityMode), so UI delegates in one call,
and drop the @SInCE tags from the new Javadoc.

On route refresh, skip components with modality that are nested inside
another one: they go away together with it and must not be taken out
of their parent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@totally-not-ai

Copy link
Copy Markdown
Contributor Author

@platosha I ran the review. I fixed three findings in fa4f8aa and left the others as they are, for the reasons below.

Fixed

  • Nested components with modality on refresh: when a component with modality sat inside another one, route refresh removed it from its parent even though it was already going away with the outer component. Refresh now skips components nested inside another tracked component. The refresh test covers this with a visually modal component inside a strict one.
  • API shape: I replaced the new setChildVisuallyModal(Component) with an overload setChildModal(Component, ModalityMode), as the conventions ask, so UI.setChildComponentModal delegates in one call. I updated the PR description's API section to match.
  • Javadoc: I removed the @since tags from the new Javadoc.

Left as is

  • Full chain refresh with a visual dialog open: refreshCurrentRoute(false) and hotswap now refresh the whole chain and close visual dialogs. That is the fix itself, and strict modals already behaved this way.
  • Visual component above a strict modal stays inert: this hasn't changed, since VISUAL never set ignore-inert before either. Changing it would be a separate behavior change.
  • Lookup cost: getActiveModalComponent now scans the stack. It holds only a handful of entries, so a separate structure isn't worth it.
  • Components set modal while detached: these stay tracked until they are detached. Strict mode already worked this way; this PR only extends it to VISUAL.

Also collect UI changes before asserting inert state in the
STRICT-to-VISUAL downgrade test so the assertion can actually fail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@vaadin-review-bot vaadin-review-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the changes — left 1 comment.

Finding
⚠️ Dialog's own applyModality() undoes the new VISUAL tracking, so the fix misses several common paths

@totally-not-ai

Copy link
Copy Markdown
Contributor Author

@sonarqubecloud Fixed in the latest commit: addToModalComponent now uses instanceof HasComponents hasComponents instead of a separate cast.

@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown
Contributor

Documentation Bot: No documentation needed for this change.

This is a bug fix: dialogs using the default visual modality (ModalityMode.VISUAL) were not tracked on the server side, so route refreshes and hotswap did not refresh them, leaving stale content visible. The fix tracks visually modal components the same way strictly modal ones already were. The new tracking methods (hasModalityComponent(), getModalityComponents(), setChildModal(Component, ModalityMode)) are on the internal UIInternals class, not part of the documented public modality API, and the existing documented behavior of UI.hasModalComponent(), addModal(), and setChildComponentModal() is unchanged. No reader of articles/flow/advanced/server-side-modality.adoc or the Dialog docs needs to do anything differently.

Nothing was opened in vaadin/docs. If you disagree, the change has to be documented by hand there.

Generated by Documentation Bot for #25417 · agent · 56.9 AIC · ⊞ 11.7K · ◷

platosha pushed a commit that referenced this pull request Oct 16, 2026
… (CP: 25.2) (#26487)

This PR cherry-picks changes from the original PR #25417 to branch 25.2.

> [!WARNING]
> The cherry-pick had merge conflicts that were resolved automatically
by Claude Code. Please review the changes carefully.

---

> Dialogs are visually modal by default since 25.0, but
`ModalityMode.VISUAL` was mapped to `setChildModeless`, so a component
with visual modality was not tracked on the server side at all.
> 
> Both code paths that deal with overlays attached to the UI instead of
the route were guarded by `UI.hasModalComponent()`, so with an open
dialog they became no-ops:
> 
> - `AbstractNavigationStateRenderer` no longer detached the dialog on a
route refresh, leaving it visible with outdated contents.
> - `Hotswapper` no longer requested a refresh of the whole route chain.
> 
> ## What changed
> 
> - Components set to `ModalityMode.VISUAL` are now tracked in
`UIInternals` without making the UI inert. The meaning of
`hasModalComponent()` and the inert semantics are unchanged; the new
`hasModalityComponent()` / `getModalityComponents()` cover both strict
and visual modality, and both call sites take the new information into
account.
> - All components with modality are kept in a **single recency-ordered
stack** of (component, mode, detach registration) entries, replacing the
previous strict-only modal component stack. The active modal component
is the most recent `STRICT` entry, and the inert state of the UI and its
children is updated in one place by comparing the active modal component
before and after each modality change. A single stack keeps
`getModalityComponents()` in the order the components were set and
cannot report a component twice when it switches between modes.
> - The detach listener that stops tracking a component is registered
once per component and kept in its stack entry, so repeatedly changing
the modality of a component does not pile up listeners on its element;
it is removed when the component is set modeless.
> - Calling `setChildModal` again on the already active modal component
now moves it to the top of the stack (above any visually modal component
set after it) instead of being a no-op.
> - `UI.setChildComponentModal(Component, boolean)` still maps `false`
to `MODELESS`, which now also clears visual modality; its Javadoc points
visually modal components to the `ModalityMode` overload. `Dialog` needs
to report its actual mode through that overload for the fix to cover all
paths (re-attach, `setVisible`, `setModality` on an open dialog,
add-then-open) — companion change: vaadin/flow-components#10440.
> - `cleanModalComponents()` in `AbstractNavigationStateRenderer` now
removes all components with modality on `REFRESH_ROUTE`, instead of
draining only the strict-modal stack. Modeless components are left
untouched.
> 
> Fixes #25415
> 
> ## API Changes
> 
> ### com.vaadin.flow.component.internal.UIInternals
> 
> ```java
> // Added
> public boolean hasModalityComponent() // true if a child component
with STRICT or VISUAL modality is set; unlike hasModalComponent() it
also counts components that only show a modality curtain
> public List<Component> getModalityComponents() // child components
with STRICT or VISUAL modality, most recently set first, never null
> public void setChildModal(Component child, ModalityMode mode) //
overload of setChildModal(Component) that sets any modality mode; VISUAL
tracks the child as having modality without making the UI and its other
components inert
> ```
> 
> 
>

Co-authored-by: totally-not-ai[bot] <290682512+totally-not-ai[bot]@users.noreply.github.com>
vaadin-bot added a commit to vaadin/flow-components that referenced this pull request Oct 16, 2026
… (CP: 25.3) (#10449)

This PR cherry-picks changes from the original PR #10440 to branch 25.3.

---

> **Review risk:** two-way door — Dialog only; no behavior change with
the current Flow version
> 
> ## Summary
> `Dialog.applyModality()` reduced the dialog state to a boolean
(`opened && visible && modality == STRICT`) and passed it to
`UI.setChildComponentModal(Component, boolean)`, which maps `false` to
`MODELESS`. An open, visible dialog in `ModalityMode.VISUAL` was
therefore reported to the UI as modeless. This passes the dialog's
actual `ModalityMode` instead (`MODELESS` when closed or hidden).
> 
> Companion to vaadin/flow#25417, which makes the UI track `VISUAL`
components (so that route refresh and hotswap rebuild the full route
chain while a visually modal dialog is open). Without this change,
`Dialog.applyModality()` drops a visual dialog from that tracking
whenever it runs: `setModality(VISUAL)` or `setVisible(...)` on an open
dialog, re-attaching a dialog, or `ui.add(dialog)` followed by `open()`.
> 
> ## What changed
> - `Dialog.applyModality()` calls `UI.setChildComponentModal(Component,
ModalityMode)` with the dialog's modality while it is opened and
visible, and `MODELESS` otherwise.
> - No behavior change with current Flow: `UI` currently treats `VISUAL`
like `MODELESS` on the server. `STRICT` handling is unchanged.
> 
> ## Test summary
> - Existing dialog modality and dialog unit tests pass.
> - Verified locally against a Flow build that includes
vaadin/flow#25417: setting `VISUAL` on an open dialog, toggling
visibility, re-attaching an auto-added dialog, and add-then-open all
keep the dialog tracked (all four failed before this change). Tests
asserting that tracking can be added once the Flow API is released.
> 
> 🤖 Generated with [Claude Code](https://claude.com/claude-code)
>

Co-authored-by: totally-not-ai[bot] <290682512+totally-not-ai[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
platosha added a commit that referenced this pull request Oct 16, 2026
The cherry-pick of #25417 used
`Component.findAncestor(SerializablePredicate)`, which was added to main
by #26035 and is marked `@since 25.4`. The 25.3 branch only has the
`findAncestor(Class)` overload, so `flow-server` failed to compile with
"incompatible types: Class is not a functional interface".

Walk the ancestors with a local helper instead, mirroring the existing
`isComponentElementEqualsOrChild` idiom in the same class. Semantics are
unchanged: the component itself is not tested, only its ancestors, so a
component with modality nested inside another one is still left in its
parent. No public API is added to the maintenance branch.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
platosha added a commit that referenced this pull request Oct 16, 2026
… (CP: 25.3) (#26488)

This PR cherry-picks changes from the original PR #25417 to branch 25.3.

---

> Dialogs are visually modal by default since 25.0, but
`ModalityMode.VISUAL` was mapped to `setChildModeless`, so a component
with visual modality was not tracked on the server side at all.
> 
> Both code paths that deal with overlays attached to the UI instead of
the route were guarded by `UI.hasModalComponent()`, so with an open
dialog they became no-ops:
> 
> - `AbstractNavigationStateRenderer` no longer detached the dialog on a
route refresh, leaving it visible with outdated contents.
> - `Hotswapper` no longer requested a refresh of the whole route chain.
> 
> ## What changed
> 
> - Components set to `ModalityMode.VISUAL` are now tracked in
`UIInternals` without making the UI inert. The meaning of
`hasModalComponent()` and the inert semantics are unchanged; the new
`hasModalityComponent()` / `getModalityComponents()` cover both strict
and visual modality, and both call sites take the new information into
account.
> - All components with modality are kept in a **single recency-ordered
stack** of (component, mode, detach registration) entries, replacing the
previous strict-only modal component stack. The active modal component
is the most recent `STRICT` entry, and the inert state of the UI and its
children is updated in one place by comparing the active modal component
before and after each modality change. A single stack keeps
`getModalityComponents()` in the order the components were set and
cannot report a component twice when it switches between modes.
> - The detach listener that stops tracking a component is registered
once per component and kept in its stack entry, so repeatedly changing
the modality of a component does not pile up listeners on its element;
it is removed when the component is set modeless.
> - Calling `setChildModal` again on the already active modal component
now moves it to the top of the stack (above any visually modal component
set after it) instead of being a no-op.
> - `UI.setChildComponentModal(Component, boolean)` still maps `false`
to `MODELESS`, which now also clears visual modality; its Javadoc points
visually modal components to the `ModalityMode` overload. `Dialog` needs
to report its actual mode through that overload for the fix to cover all
paths (re-attach, `setVisible`, `setModality` on an open dialog,
add-then-open) — companion change: vaadin/flow-components#10440.
> - `cleanModalComponents()` in `AbstractNavigationStateRenderer` now
removes all components with modality on `REFRESH_ROUTE`, instead of
draining only the strict-modal stack. Modeless components are left
untouched.
> 
> Fixes #25415
> 
> ## API Changes
> 
> ### com.vaadin.flow.component.internal.UIInternals
> 
> ```java
> // Added
> public boolean hasModalityComponent() // true if a child component
with STRICT or VISUAL modality is set; unlike hasModalComponent() it
also counts components that only show a modality curtain
> public List<Component> getModalityComponents() // child components
with STRICT or VISUAL modality, most recently set first, never null
> public void setChildModal(Component child, ModalityMode mode) //
overload of setChildModal(Component) that sets any modality mode; VISUAL
tracks the child as having modality without making the UI and its other
components inert
> ```
> 
> 
>

Co-authored-by: totally-not-ai[bot] <290682512+totally-not-ai[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Anton Platonov <anton@vaadin.com>
vaadin-bot added a commit that referenced this pull request Oct 16, 2026
…2) (#26497)

This PR cherry-picks changes from the original PR #26425 to branch 25.2.

---

> **Review risk:** two-way door — changes where overlays such as
notifications, context menus and nested dialogs are attached while a
visually modal dialog is open; easy to revert.
> 
> Fixes #25136
> Builds on #25417 (merged)
> 
> **Behavior deviation** · flow-server · apps that open an overlay while
a default (visually modal) `Dialog` is open
> 
> ## Summary
> 
> An overlay opened while a visually modal dialog is showing was
attached to the UI, outside the dialog. The dialog's modality curtain
blocks pointer events and traps focus outside of it, so the overlay
could not be clicked or reached with the keyboard. Overlays are now
nested inside the most recently opened strictly or visually modal
component.
> 
> **Risks:**
> - ⚠️ Behavior change: an overlay opened while a visually modal
component is showing now becomes a child of that component, so it is
removed together with it. This is the same as with strictly modal
components. Before, it was attached to the UI, where the user could not
reach it on the client.
> - ⚠️ Public API: one method added to the internal `UIInternals`.
> - ✅ No security, memory, serialization, threading, performance or
migration impact.
> 
> ## What changed
> 
> - Added `UIInternals.getActiveModalityComponent()`, which returns the
most recently set component with `STRICT` or `VISUAL` modality, based on
the modality stack from #25417.
> - Made `UI.addToModalComponent()` add to that component instead of
only to the active strictly modal one.
> - Left `hasModalComponent()`, `getActiveModalComponent()` and all
inert handling unchanged, so the UI is still only inert for `STRICT`,
and shortcut routing through the inert-escaping component works as
before.
> 
> ## Test summary
> 
> - An overlay opened while only a visually modal component is showing
is nested into it (this flips the test from #25417 that pinned the old
attach-to-UI behavior).
> - An overlay is nested into a visually modal component opened on top
of a strictly modal one.
> - A strictly modal component opened on top of a visually modal one is
nested in it, its overlays are nested in it and stay interactive, and
nesting goes back to the visually modal component once it is removed.
> - Existing UI, shortcut and route refresh unit tests pass.
> 
>

Co-authored-by: totally-not-ai[bot] <290682512+totally-not-ai[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
vaadin-bot added a commit that referenced this pull request Oct 16, 2026
…3) (#26498)

This PR cherry-picks changes from the original PR #26425 to branch 25.3.

---

> **Review risk:** two-way door — changes where overlays such as
notifications, context menus and nested dialogs are attached while a
visually modal dialog is open; easy to revert.
> 
> Fixes #25136
> Builds on #25417 (merged)
> 
> **Behavior deviation** · flow-server · apps that open an overlay while
a default (visually modal) `Dialog` is open
> 
> ## Summary
> 
> An overlay opened while a visually modal dialog is showing was
attached to the UI, outside the dialog. The dialog's modality curtain
blocks pointer events and traps focus outside of it, so the overlay
could not be clicked or reached with the keyboard. Overlays are now
nested inside the most recently opened strictly or visually modal
component.
> 
> **Risks:**
> - ⚠️ Behavior change: an overlay opened while a visually modal
component is showing now becomes a child of that component, so it is
removed together with it. This is the same as with strictly modal
components. Before, it was attached to the UI, where the user could not
reach it on the client.
> - ⚠️ Public API: one method added to the internal `UIInternals`.
> - ✅ No security, memory, serialization, threading, performance or
migration impact.
> 
> ## What changed
> 
> - Added `UIInternals.getActiveModalityComponent()`, which returns the
most recently set component with `STRICT` or `VISUAL` modality, based on
the modality stack from #25417.
> - Made `UI.addToModalComponent()` add to that component instead of
only to the active strictly modal one.
> - Left `hasModalComponent()`, `getActiveModalComponent()` and all
inert handling unchanged, so the UI is still only inert for `STRICT`,
and shortcut routing through the inert-escaping component works as
before.
> 
> ## Test summary
> 
> - An overlay opened while only a visually modal component is showing
is nested into it (this flips the test from #25417 that pinned the old
attach-to-UI behavior).
> - An overlay is nested into a visually modal component opened on top
of a strictly modal one.
> - A strictly modal component opened on top of a visually modal one is
nested in it, its overlays are nested in it and stay interactive, and
nesting goes back to the visually modal component once it is removed.
> - Existing UI, shortcut and route refresh unit tests pass.
> 
>

Co-authored-by: totally-not-ai[bot] <290682512+totally-not-ai[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
vaadin-bot added a commit to vaadin/flow-components that referenced this pull request Oct 16, 2026
…5.3) (#10459)

This PR cherry-picks changes from the original PR #10457 to branch 25.3.

---

> ## Description
> 
> Related to vaadin/flow#26425
> 
> Flow now adds auto-added overlays to the most recent component with
`STRICT` or `VISUAL` modality, not only `STRICT`. This change came in
vaadin/flow#26425, which builds on vaadin/flow#25417.
`DialogModalityTest` still expected the old behavior and failed.
> 
> - Renamed `visualModal_openSecondDialog_addedToUI` to
`visualModal_openSecondDialog_addedToFirstDialog` and changed it to
expect the first dialog as the parent of a second dialog opened over a
visually modal dialog
> 
> ## Type of change
> 
> - Tests
>

Co-authored-by: Sascha Ißbrücker <sissbruecker@vaadin.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
caalador pushed a commit to AzazelSensei/flow that referenced this pull request Oct 20, 2026
**Review risk:** two-way door — changes where overlays such as
notifications, context menus and nested dialogs are attached while a
visually modal dialog is open; easy to revert.

Fixes vaadin#25136
Builds on vaadin#25417 (merged)

**Behavior deviation** · flow-server · apps that open an overlay while a
default (visually modal) `Dialog` is open

## Summary

An overlay opened while a visually modal dialog is showing was attached
to the UI, outside the dialog. The dialog's modality curtain blocks
pointer events and traps focus outside of it, so the overlay could not
be clicked or reached with the keyboard. Overlays are now nested inside
the most recently opened strictly or visually modal component.

**Risks:**
- ⚠️ Behavior change: an overlay opened while a visually modal component
is showing now becomes a child of that component, so it is removed
together with it. This is the same as with strictly modal components.
Before, it was attached to the UI, where the user could not reach it on
the client.
- ⚠️ Public API: one method added to the internal `UIInternals`.
- ✅ No security, memory, serialization, threading, performance or
migration impact.

## What changed

- Added `UIInternals.getActiveModalityComponent()`, which returns the
most recently set component with `STRICT` or `VISUAL` modality, based on
the modality stack from vaadin#25417.
- Made `UI.addToModalComponent()` add to that component instead of only
to the active strictly modal one.
- Left `hasModalComponent()`, `getActiveModalComponent()` and all inert
handling unchanged, so the UI is still only inert for `STRICT`, and
shortcut routing through the inert-escaping component works as before.

## Test summary

- An overlay opened while only a visually modal component is showing is
nested into it (this flips the test from vaadin#25417 that pinned the old
attach-to-UI behavior).
- An overlay is nested into a visually modal component opened on top of
a strictly modal one.
- A strictly modal component opened on top of a visually modal one is
nested in it, its overlays are nested in it and stay interactive, and
nesting goes back to the visually modal component once it is removed.
- Existing UI, shortcut and route refresh unit tests pass.

---------

Co-authored-by: totally-not-ai[bot] <290682512+totally-not-ai[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@vaadin-bot

Copy link
Copy Markdown
Collaborator

This ticket/PR has been released with Vaadin 25.4.0-alpha4.

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

Projects

Development

Successfully merging this pull request may close these issues.

Changes to the Dialog are not reflected in the UI after HotSwap

3 participants