Skip to content

[Dialog] Fixes Dialog so that it can be reopened after closing with escape key when declared in markup - #5573

Merged
Vincent Baaij (vnbaaij) merged 3 commits into
microsoft:devfrom
bryan-ramirez:fix-dialog-onstatechange-declarative
Oct 29, 2026
Merged

Vincent Baaij (vnbaaij) merged 3 commits into
microsoft:devfrom
bryan-ramirez:fix-dialog-onstatechange-declarative

Conversation

@bryan-ramirez

Copy link
Copy Markdown
Contributor

Pull Request

📖 Description

Fix. FluentDialog.OnToggleAsync assumes that the dialog was instantiated using the DialogService. If the dialog is declared in markup the Id check fails because Instance is null. The result is that I can open a dialog, and close it using the escape key but can then cannot reopen it without reloading the page.

🎫 Issues

Fixes #5572

👩‍💻 Reviewer Notes

The check was added in #3758 to ignore child combobox toggles. Comparing against Id keeps that behavior and also covers declarative dialogs.

📑 Test Plan

No existing tests were modified. FluentDialog_Toggle exercises the changed check when instantiating a dialog through DialogService and passes unchanged.

Added FluentDialog_Toggle_Standalone. A dialog created in markup now raises OnStateChange for its toggle event and still ignores ones with different ids. The test fails without my fix, and passes with it.

When I ran the full test suite all but 6 tests pass. The 6 failures are FluentCalendarTests.FocusAsync_* from #5515. They fail on the unmodified dev branch and are unrelated to this change.

I ran a manual test by packing the branch as a local NuGet package and confirmed that I can reopen a dialog as expected.

✅ Checklist

General

  • I have added tests for my changes.
  • I have tested my changes.
  • I have updated the project documentation to reflect my changes.
  • I have read the CONTRIBUTING documentation and followed the standards for this project.

Issue discussion declaration

Discuss changes before implementing them to confirm that the problem and proposed approach fit the project. See Discuss before implementing for the process and exceptions.

  • I have discussed this change in an issue and received maintainer agreement before implementation, or a documented exception applies.

AI contribution declaration

AI assistance is allowed; fully AI-generated or autonomous pull requests without meaningful human review are not accepted. See the AI contribution policy.

  • I have read and followed the AI contribution policy.
  • I have personally reviewed and understood all changes, tested them, and take responsibility for this contribution.

Component-specific

  • I have added a new component
  • I have added Unit Tests for my new component
  • I have modified an existing component
  • I have validated the Unit Tests for an existing component

MCP Server

  • I have added or updated MCP Server tools/prompts/resources
  • I have added Unit Tests for my MCP Server changes

⏭ Next Steps

Copilot AI balanced review requested due to automatic review settings October 28, 2026 20:19
@bryan-ramirez
bryan-ramirez marked this pull request as ready for review October 28, 2026 20:21

Copilot AI 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.

🟢 Approval recommended

No active review issues were identified for the dialog toggle-handling change.

No open issues 🎉

What changed in this PR

Fixes #5572 so markup-declared FluentDialog components can reopen after being closed with Escape, while preserving the child-toggle filtering introduced in #3758.

Changes:

  • Matches toggle events against the component’s Id rather than the nullable service-created Instance.
  • Adds a standalone-dialog regression test verifying close notifications and rejection of events with unrelated IDs.
File Description
tests/​Core/​Components/​Dialog/​FluentDialogTests.razor Adds regression coverage for standalone dialog toggle handling.
src/​Core/​Components/​Dialog/​FluentDialog.razor.cs Uses the component ID to recognize its own toggle events.

Review effort: Balanced

@bryan-ramirez

bryan-ramirez commented Oct 28, 2026 via email

Copy link
Copy Markdown
Contributor Author

@bryan-ramirez

bryan-ramirez commented Oct 28, 2026 via email

Copy link
Copy Markdown
Contributor Author

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.

fix: Cannot reopen dialog after closing with escape key in FluentDialog

4 participants