[dev-v5] Fix dialog shortcut handling and simplify active element retrieval - #5213
Conversation
…andling in dialog
There was a problem hiding this comment.
Pull request overview
This PR addresses a regression in dialog/message box keyboard shortcut handling by simplifying how the active element is detected for shortcut eligibility, ensuring shortcuts can work when the dialog surface itself holds focus (notably in MessageBox scenarios).
Changes:
- Updated dialog shortcut eligibility logic to use
document.activeElementand explicitly allow shortcuts when the dialog surface is focused. - Added a unit test validating confirmation MessageBox behavior when
Y/Nshortcuts are pressed.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/Core/Components/Dialog/FluentMessageBoxTests.razor | Adds coverage for confirmation shortcut key handling in MessageBox. |
| src/Core.Scripts/src/Components/Dialog/FluentDialog.ts | Simplifies active element detection for shortcut handling and enables shortcuts when dialog itself has focus. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
✅ All tests passed successfully Details on your Workflow / Core Tests page. |
Summary - Unit Tests Code CoverageSummary
CoverageMicrosoft.FluentUI.AspNetCore.Components - 98.3%
Microsoft.FluentUI.AspNetCore.Components.Charts - 100%
|
Vincent Baaij (vnbaaij)
left a comment
There was a problem hiding this comment.
As you mention the DataGrid issues, I assume it is verified that those remain fixed after removing the getDeep...
Yes, I tested using the "DataGrid" sample in #4562 |
[dev-v5] Fix dialog shortcut handling and simplify active element retrieval
Fixes #5212, #4983 and #4562
Enhance the dialog's shortcut handling by simplifying the retrieval of the active element.
This change improves the user experience by ensuring that shortcuts function correctly within the dialog context.
Additionally, tests have been added to verify the expected behavior when shortcuts are pressed.
Note: The
getDeepActiveElementfunction was removed because dialog shortcut handling must evaluate the focused Web Component host, while traversing into its Shadow DOM prevents reliable detection of whether focus belongs to the dialog or its action area.Unit Tests
Added