Roving-focus re-focus dismisses a just-opened modal Dialog (focusin light-dismiss)
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 85/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- rust
- Domain
- accessibility
Research direction
Start by examining the async re-focus logic in collection.rs around line 319 and the capturing focusin light-dismiss handler in dialog.rs around line 231 to confirm the reported race condition. Implement one of the two suggested fixes: either guard the async set_focus call to only run if document.activeElement is still inside the collection root, or modify the dialog handler to skip light-dismiss for modal dialogs when focus moves outside. Run the relevant component tests to verify the dialog stays open when opened immediately after a roving-focus selection change, and that non-modal dialog light-dismiss behavior remains intact.
Written by the indexing model from the issue text.
Description
Versions: dioxus 0.7.10 (desktop renderer, WKWebView on macOS); dioxus-primitives at 9a758255ea26e2b20c8cecf4c1c946feb9e71da7 (2026-09-07).
What happens
If a modal Dialog is opened right after a roving-focus collection (Tabs, RadioGroup, …) changes its focused item, the dialog opens and then immediately closes.
Steps to reproduce
- Render a
Tabs(orRadioGroup), and a modalDialogRootopened by a global keyboard shortcut (we use ⌘K for a command palette). - Focus the tab list and press
End. The selection moves to the last tab. - Press the shortcut immediately, within a frame or two.
Expected: the dialog opens and stays open, with focus inside it.
Actual: the dialog opens and is dismissed at once. Focus ends up back on the tab. Pressing the shortcut again, after a moment, works.
The same happens after a pointer click that focuses the tab, on engines where a click focuses buttons (Chromium-based webviews, for example). WKWebView doesn't focus a button on click, so there only the keyboard path is exposed.
Why (from the source at 9a75825)
- After a focus or selection change, the collection item re-focuses itself asynchronously.
collection.rscontrol_mount_focus(around line 319) callsspawn(async move { md.set_focus(true).await })wheneveris_focused(index)is true. Thatset_focuslands one eval round trip later. DialogContentregistersuse_outside_dismiss(dialog.rsaround line 231;lib.rsaround lines 212-229). It light-dismisses on a capturingfocusinwhose target is outside the dialog root, and it does this for modal dialogs too.- So the dialog opens and the focus trap moves focus inside. Then the collection's pending
set_focusfires and focuses the tab outside the dialog. Thatfocusinis treated as an outside interaction, and the dialog closes.
Suggested fixes (either would solve it)
- In the collection: only re-focus the item if focus is still within the collection, meaning
document.activeElementis inside the collection root when the asyncset_focusruns. A late re-focus shouldn't steal focus that has moved elsewhere in the meantime. - In the dialog: don't light-dismiss a modal dialog on
focusinoutside. A modal dialog already traps focus, and the WAI-ARIA dialog pattern doesn't close a modal dialog when focus moves programmatically. Keeppointerdown-outside dismissal for non-modal dialogs and popovers.
Happy to test a patch against our app.
- Dominant language
- Rust
- Stars
- 358
- Forks
- 90
- Avg merge
- 54m
- Merged PRs (30d)
- 1
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from DioxusLabs/dioxus-components
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
DioxusLabs/dioxus-components#294 ·
-
Range SliderOpen
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
DioxusLabs/dioxus-components#292 · 2 comments ·
-
Component library depends on `dioxus` crate with default features enabledPossibly taken @ealmloff claimed this 185 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
DioxusLabs/dioxus-components#272 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
DioxusLabs/dioxus-components#321 ·
-
Drag and drop list not reactivePossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 3/5 1-2 days Newbie friendliness 40/100
DioxusLabs/dioxus-components#319 · 1 comment ·
All issues in DioxusLabs/dioxus-components
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
mongodb/kingfisher#588 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
bug rust
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 2 days
-
type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
franciscoBSalgueiro/en-croissant#1111 ·
Maintainers usually reply within 2 days
-
[bug] Toolchain versions from `.prototools` are not inherited when moon runs from a subdirectoryOpen
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day