Skip to content

fix(focus): drop focus handoff when modal returns focus to nothing - #3311

Merged
Hona merged 1 commit into
devfrom
fix/3284-modal-return-focus-drop
Dec 2, 2026
Merged

Hona merged 1 commit into
devfrom
fix/3284-modal-return-focus-drop

Conversation

@Hona

@Hona Hona commented Dec 2, 2026

Copy link
Copy Markdown
Member

Fixes #3284

Summary

When a closing modal returns focus to nowhere (either because nothing had focus before it opened or because its saved restore target can no longer take focus), ModalEffect::Return now steps FocusEvent::Dropped and FocusEvent::Settled, matching Tx::blur.

Why

Closing a modal with a focused text_input left Focus::None { from: Some(field), blurred, handoff: true } with Modality::Keyboard while the modal and its field played their exit animation. On a subsequent commit, once modal_scope no longer contained the exiting modal, focus_fallback treated handoff: true as a non-modal blurred field leaving the tree and rescued focus onto a control behind the closed dialog.

Verification

  • Reproduced failures on dev before the fix with focused regression tests covering Escape and programmatic close (restore: None), disabled/removed restore target with a focused modal text field, and pane-scoped modals (El::modal_scope).
  • cargo test -j 1 -p rune --lib modal (94 passed, 0 failed)
  • cargo test -j 1 -p rune --lib focus (322 passed, 0 failed)
  • cargo clippy -j 1 -p rune --lib --tests --no-deps (pass)
  • cargo check -j 1 -p rune --target wasm32-unknown-unknown (pass)
  • scripts/file-size.sh (0 errors)

Copilot AI balanced review requested due to automatic review settings December 2, 2026 15:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@Hona
Hona merged commit c2cf592 into dev Dec 2, 2026
7 checks passed
@Hona
Hona deleted the fix/3284-modal-return-focus-drop branch December 2, 2026 15: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.

A modal that returns focus to nothing lets it land later on a control behind the dialog

2 participants