Skip to content

fix(Overlay): let a controller on the overlay dismiss it - #1335

Merged
mstijak merged 1 commit into
masterfrom
fix/overlay-own-dismiss
Sep 24, 2026
Merged

mstijak merged 1 commit into
masterfrom
fix/overlay-own-dismiss

Conversation

@mstijak

@mstijak mstijak commented Sep 24, 2026

Copy link
Copy Markdown
Member

Fixes #1332.

Problem

A controller attached to a Window (or any overlay) could not close it:

class EditorController extends Controller {
  onSave() {
    this.instance.parentOptions.dismiss(); // parentOptions.dismiss was undefined
  }
}

<Window visible={m.editor.visible} controller={EditorController}>…</Window>

The same controller worked when attached to an element inside the window.

Instance.explore copies context.parentOptions onto the instance before the widget's own explore runs. Overlay.explore computes dismiss and pushes it for its children only after that, so the overlay's own instance never received it.

Change

Overlay.explore now assigns the options object it pushes for its children to its own instance as well, so the overlay and its content see the same dismiss. Only the overlay's own instance changes; Button (dismiss) and MsgBox, the other readers of parentOptions, read it on instances inside the overlay.

Tests

New Window.spec.tsx renders an inline window and calls dismiss() from a controller attached to the window and from one inside it, checking that the bound visible becomes false. The first case failed before the change.

  • yarn workspace cx run test: 537 passing, 2 pending, 0 failing
  • yarn workspace cx run check-types: no errors

The overlay instance copied parentOptions before the overlay computed its dismiss, so this.instance.parentOptions.dismiss was undefined for a controller attached to the Window itself. The overlay now also gives its own instance the options it pushes for its children. Fixes #1332.
@mstijak
mstijak merged commit 0d45929 into master Sep 24, 2026
2 checks passed
@mstijak
mstijak deleted the fix/overlay-own-dismiss branch September 24, 2026 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Controller attached to a Window cannot dismiss it via this.instance.parentOptions

1 participant