Issue Bug Resolved

#108965Restore focus to triggering element after closing modal dialogs

Christian Jung 02/12/26, 15:05 updated 11/04/26, 14:25

Description

After closing modal dialog windows (e.g. the confirmation dialog for resetting user settings), the keyboard focus is currently moved to the top of the page. Keyboard users lose their orientation and have to tab a lot to get back to the element they used before. This is problematic from an accessibility perspective.

Steps to reproduce

  1. Log in to the TYPO3 backend.
  2. Open a module that uses a modal confirmation dialog (e.g. User Settings).
  3. Trigger an action that opens a modal confirmation dialog (e.g. “Reset user settings”).
  4. Close the dialog via “OK”, “Cancel”, close icon or Esc.
  5. Press Tab and check where the focus is.

Current result

Focus is set to the top of the page (e.g. first link / menu item) instead of the element that opened the dialog.

Expected result

After closing the dialog, focus is returned to the control that opened the dialog.

Impact

  • Keyboard users need significantly more navigation steps.
  • Users lose their orientation within the backend.
  • Violates common accessibility best practices (focus management, keyboard accessibility).

Recommended solution

  • When opening a modal dialog, store the currently focused element.
  • When closing the dialog, always restore focus to that element (regardless of whether the dialog was closed via button, Esc or click outside).
  • If the triggering element no longer exists (e.g. disabled or removed), move focus to a meaningful alternative in the same context (e.g. next button in the toolbar).
  • Implement this centrally in the modal API used by the backend so that all modal dialogs benefit from it.

Definition of Done

  • For all backend modal dialogs, focus is restored by default to the triggering element (or a sensible alternative) after closing.
  • Works consistently across all supported browsers.
  • Behavior is fully testable using keyboard only and does not introduce regressions for mouse users.

Acceptance criteria

  • After opening and closing the “Reset user settings” confirmation dialog (closed via “OK”), focus is back on the button/link that opened the dialog.
  • After closing the same dialog via “Cancel”, focus is also back on the triggering element.

Reviews 2

Files 1

History 611

  1. Oliver Bartsch commented <span data-processor="relativetime" data-value="2026-10-21T10:05:30+00:00" > 10/21/26, 10:05 </span>

    Hey,

    thanks for the detailed report. I can confirm it. Backend modals are always rendered in the top window, but the button that opens them usually sits inside the module frame, like “Reset configuration” in User Settings. When the dialog closes, the browser can only return the focus to the module frame as a whole, not to the button inside it, so keyboard users end up at the start of the module. Dialogs opened from the top frame itself (toolbar, page tree) already got their focus back.

    I pushed a patch that changes this centrally in the modal API, so every backend modal benefits from it. When a modal is created, it now remembers the focused element, also inside the module frame, and focuses it again after the modal closed, whether via a button, the close icon, Esc or a click on the backdrop. If that element no longer exists, the focus is left alone. Code that moves the focus somewhere else after a modal closed still takes precedence. The fix targets main and 14.3. TYPO3 v13 still uses the Bootstrap based modal, so it is not covered.

    Cheers, Oli

  2. Oliver Bartsch commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2026-11-04T14:25:18+00:00" > 11/04/26, 14:25 </span>

    Applied in changeset commit:e4d5daedeb47fefa5c3171fcd21d5fff7c4f0c0c.