Skip to content

[ModalPane] Focus retention on hidden elements & Inconsistent onClose triggering #165

@MinYu5263

Description

@MinYu5263

Issue 1: Internal TextField focus is not released after ModalPane is hidden

Description: When a text field inside a ModalPane acquires focus and the modal is subsequently closed (hidden) by clicking the outside area or pressing ESC, the focus is not released from the text field.

This results in "focus trapping" on an invisible element:

  1. Subsequent keyboard inputs continue to be captured by the hidden text field.
  2. Global keyboard shortcuts (e.g., triggering the modal via /) fail to work because the event is consumed by the focused (but hidden) text field.
  3. When the ModalPane is reopened, the unintended input typed while it was hidden becomes visible.

Steps to reproduce:

  1. Open a ModalPane that contains a TextField.
  2. Click the TextField to give it focus.
  3. Close the modal by clicking the outside overlay or pressing ESC.
  4. Type some random characters on the keyboard.
  5. Reopen the same ModalPane.
  6. Observation: The characters typed in step 4 appear in the text field.

Reproduction in AtlantaFX Sampler:

  • Scenario 1: Press / to open the search box. Focus the input field. Close it by pressing ESC or clicking outside. Press / again.
    • Result: The search box does not open because the focus is still trapped in the hidden input field.
  • Scenario 2: In the "ModalBox" sample, click the button to open the modal, focus the text field, and then close the modal. Type randomly. Open the modal again.
    • Result: The input content is visible.

Issue 2: Clicking the overlay mask does not trigger the onClose event

Description: When closing the modal by clicking the gray overlay mask outside the ModalPane, the configured onClose callback is not triggered.

This behavior is inconsistent with closing the modal via the ESC key (or the close button), which correctly triggers onClose. This prevents developers from reliably handling cleanup logic (such as clearing focus or resetting state) in a unified way.

Steps to reproduce:

  1. Open a ModalPane with an onClose event handler attached.
  2. Click the gray overlay/mask area outside the modal to close it.
  3. Observation: The onClose event is NOT triggered.
  4. (Contrast) Open the ModalPane again and press ESC. The onClose event IS triggered.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions