Review main Merged

79555[BUGFIX] Use event delegation for image manipulation triggers

Andreas Kienast CR +2 V +2 Normal +29 −32 updated 07/03/23, 16:03

Commit message

With the dismissal of jQuery and jQuery UI from the image manipulation
component, the event handling for the trigger button ("Open Editor")
got borked as the event state toggling previously done via
`.off(...).on(...)` was replaced with using a `signal` as
documented at [1]. The `AbortController` instance is only built when
the modal has been fully shown, way after the event handling took
place, breaking the module's global state.

To solve this issue we removed the `AbortController` and its usages
again. Also, `initializeTrigger()` now uses event delegation to register
the event handler on the trigger buttons.

As a drive-by fixes, the `active` state of the ratio buttons is now
properly toggled, and the ratio title field is correctly updated by
comparing with the scoped `ratioTitleWindow.HTMLElement` prototype.

[1] https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#add_an_abortable_listener

Review

  • Code review CR +2 Done
    • Andreas Kienast +2
    • Thomas Hohn +1
    • Markus Klein +1
    • Oliver Hader +1
    • Benni Mack +1
  • Verified V +2 Done
    • Andreas Kienast +2
    • Oliver Hader +1
    • Benni Mack +1
    • core-ci +1 CI

Issues 3

Files 2

Review log 1825

  1. Andreas Kienast uploaded patch set 1 06/29/23, 06:20

  2. Andreas Kienast updated the commit message in patch set 2 06/29/23, 06:21

  3. core-ci voted on patch set 1 V +1 06/29/23, 06:28 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/43098

  4. core-ci voted on patch set 2 V +1 06/29/23, 06:39 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/43099

  5. Andreas Kienast uploaded patch set 3 V +1 06/29/23, 06:42

  6. core-ci voted on patch set 3 V +1 06/29/23, 06:50 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/43100

  7. Andreas Kienast uploaded patch set 4 V +1 06/29/23, 07:12

  8. core-ci voted on patch set 4 V +1 06/29/23, 07:19 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/43101

  9. Oliver Hader commented on patch set 4 06/29/23, 07:24

    What about just bringing back the previous behavior - the jQuery `$.off` function ensured that the trigger was just registered once, e.g. like ``` public initializeTrigger(): void { // this initializer is created multiple times when adding new images if (this.triggerListener) { return; } this.triggerListener = new RegularEvent( 'click', (evt: Event, target: HTMLElement): void => { evt.preventDefault(); this.trigger = target; this.show(); }, this.abortEventListenerOptions ); this.triggerListener.delegateTo(document, '.t3js-image-manipulation-trigger'); } ```
  10. Andreas Kienast commented on patch set 4 06/29/23, 07:29

    Reply

    Hm, I've added a `console.log()` in `initializeTrigger()` and the method gets called only once - for the image being added. Let's have a chat about this.
  11. Andreas Kienast uploaded patch set 5 V +1 06/29/23, 08:00

  12. core-ci voted on patch set 5 V +1 06/29/23, 08:09 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/43102

  13. Oliver Hader uploaded patch set 6 V +1 06/29/23, 08:52

  14. Oliver Hader voted on patch set 6 V +1 CR +1 06/29/23, 08:53

  15. core-ci voted on patch set 6 V +1 06/29/23, 09:00 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/43103

  16. Jasmina Ließmann voted on patch set 6 V +1 06/29/23, 09:36

  17. Oliver Hader commented on patch set 6 CR -1 06/29/23, 14:52

    Another drive-by fix...
  18. Oliver Hader uploaded patch set 7 CR -1 V +1 06/29/23, 14:55

  19. Oliver Hader voted on patch set 7 V +1 CR +1 06/29/23, 14:55

  20. core-ci voted on patch set 7 V +1 06/29/23, 15:04 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/43117

  21. Markus Klein voted on patch set 7 CR +1 06/30/23, 10:33

  22. Thomas Hohn voted on patch set 7 CR +1 06/30/23, 10:36

  23. Benni Mack voted on patch set 7 V +1 CR +1 07/03/23, 12:43

  24. Andreas Kienast voted on patch set 7 V +2 CR +2 07/03/23, 16:03

  25. Andreas Kienast merged patch set 8 07/03/23, 16:03