Review main Merged

88902[BUGFIX] Register global keydown handler to close modals

Andreas Kienast CR +2 V +2 Easy +17 −11 updated 04/07/25, 19:28

Commit message

Usually, closing modal windows via pressing <ESC> works just fine as our
modals are based on Bootstrap. However, this may fail if a focussed
element within the modal is removed from the DOM, as the browser may
change the focus to the outer `body` element then.

To circumvent this, the Modal API will install a global `keydown`
handler that checks whether <ESC> was pressed and closes the modal then.
The event handler itself gets removed once the modal is finally closed.

Review

  • Code review CR +2 Done
    • Benni Mack +2
    • Garvin Hicking +1
    • Christian Kuhn +1
  • Verified V +2 Done
    • Benni Mack +2
    • Garvin Hicking +1
    • Christian Kuhn +1
    • core-ci +1 CI

Issues 1

Files 2

Review log 89

  1. Andreas Kienast uploaded patch set 1 04/02/25, 08:21

  2. core-ci voted on patch set 1 V +1 04/02/25, 08:28 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76848

  3. Garvin Hicking commented on patch set 1 04/02/25, 12:04

    (mobile, just feedback) would this close a modal if I hit "esc" inside a form element within the modal to close auto-completion or an active select dropdown? (can test myself later)
  4. Andreas Kienast commented on patch set 1 04/02/25, 12:21

    Reply

    Yes, but that's IMO already the case with Bootstrap in place.
  5. Garvin Hicking commented on patch set 1 CR +1 V +1 04/03/25, 07:01

    works for me, tried with a few modals and out-of-bound focussing, ESC reliably closes the modals for me

    Reply

    ack/confirmed, thanks! :)
  6. Garvin Hicking commented on patch set 1 04/03/25, 07:01

    Reply

    Done
  7. Christian Kuhn voted on patch set 1 CR +1 V +1 04/07/25, 10:43

  8. Benni Mack voted on patch set 1 CR +2 V +2 04/07/25, 19:28

  9. Benni Mack merged patch set 2 04/07/25, 19:28