Review main Merged

72328[BUGFIX] Major context menu refinements

Andreas Kienast CR +2 V +2 Normal +61 −79 updated 12/03/21, 16:47

Commit message

With #94891 the close handling of the context menus got reworked as its
previous attempt had some glitches. However, the introduced overhaul
had another glitch: The context menu should hide once the cursor has
left the context menu for at least 500ms. When the cursor is moved
within these 500ms, but is still outside the context menu, the timeout
is reset because the event handler storing the cursor's position calls
the "should I close the menu"-routine which resets all timeouts.

This patch replaces the hand-crafted timeout magic with event
debouncing, providing basically the same functionality, but in a more
reliable way. Doing so allows us to remove some code that became
obsolete by now.

The `within()` method had a minor flaw where it considered a cursor not
being within an element if the cursor position was at the exact right
or bottom boundary. The method is now based on
`getBoundingClientRect()` which appears to be more stable. Previously,
a context menu suddenly could have an offset of 0 causing some glitches
where the menus closed unexpectedly.

The cursor's position is stored all 50ms, which may lead to timing
issues between the debounced event and the last cursor update. To
circumvent this, the cursor position is now also updated when the
context menu is entered.

As additional measurements, the logic when exactly a context menu gets
closed is refined:

* close if cursor is outside the context menu AND no child menu is
  visible or available
* close parent menu if cursor leaves child menu from any boundary where
  cursor will not enter its parent menu

Review

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

Issues 2

Files 2

Review log 3447

Show 1322 earlier messages
  1. Andreas Kienast uploaded patch set 1 11/27/21, 17:09

  2. Andreas Kienast commented on patch set 1 V -1 11/27/21, 17:14

    Visibility is still flawed when contextMenu1 is opened. Argh.
  3. Stefan Bürk updated the commit message in patch set 2 11/27/21, 17:16

  4. Andreas Kienast uploaded patch set 3 11/27/21, 17:21

  5. core-ci voted on patch set 1 V +1 11/27/21, 17:22 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/19877

  6. core-ci voted on patch set 2 V +1 11/27/21, 17:27 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/19878

  7. core-ci voted on patch set 3 V +1 11/27/21, 17:35 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/19879

  8. Andreas Kienast voted on patch set 3 V -1 11/27/21, 17:46

  9. Andreas Kienast uploaded patch set 4 11/27/21, 17:49

  10. Andreas Kienast commented on patch set 4 V -1 11/27/21, 17:50

    The context menu is still quirky, I left some debug stuff in there for now...
  11. core-ci voted on patch set 4 V +1 11/27/21, 17:59 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/19881

  12. Andreas Kienast uploaded patch set 5 11/27/21, 18:14

  13. core-ci voted on patch set 5 V +1 11/27/21, 18:29 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/19884

  14. Andreas Kienast uploaded patch set 6 11/27/21, 20:54

  15. core-ci voted on patch set 6 V -1 11/27/21, 21:46 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/19898

  16. core-ci commented on patch set 6 11/27/21, 22:24 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/19898

  17. Andreas Kienast uploaded patch set 7 11/28/21, 08:46

  18. Andreas Kienast updated the commit message in patch set 8 11/28/21, 08:49

  19. core-ci voted on patch set 7 V +1 11/28/21, 08:57 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/19921

  20. core-ci voted on patch set 8 V +1 11/28/21, 09:07 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/19922

  21. Rachel Foucard commented on patch set 8 11/28/21, 09:53

    Sorry to question this approach when quite some time have already been spent on it but I wasn't aware of this work. So just a few questions: * why should a context menu disappear on the mouseout after 500ms? * why 500ms (how to guess the time that determines that the user is not thinking before clicking)? * why something that appears with a click should disappear with a mouseout + timing? * how do other contextual menus in other systems disappear (windows, apple, etc.)? seems to disappear when I click somewhere else, no timing. * why do we have to deal with the wird case of several context menus opened at the same time?!
  22. Andreas Kienast commented on patch set 8 11/28/21, 10:12

    Reply

    * With large page trees it seems not feasible to close a context menu via click only as nearly everywhere something will react on a click. * 500ms is IMO a good compromise in case somebody accidentally leaves the context menu for whatever reason, most probably by moving the mouse too fast. * Operating systems are something different, you can hardly compare with web applications, what a TYPO3 backend in fact is. * Having "several" context menus open is not weird. A context menu may have a "child" menu (aka "more options") which is a context menu again, that needs to be handled properly as well. I'm fine with replacing the ctx menu with something different in v12, as long we keep accessibility in mind as well. Until then, I'd like to fix the major issues, where v11 and v10 benefit from that as well.
  1. Rachel Foucard commented on patch set 8 11/28/21, 10:46

    Reply

    Yes, replacing the ctx menu with something different in v12, with accessibility in mind of course, and fixing the major issues in v11 and v10 is the good approach IMHO. Indeed the ctx menu is an very important feature that would need a short UX/A11y workshop before deciding how to improve it for v12. We would be happy to work on that. AFAIK, ctx menu in other systems or web applications don't disappear on mouseout + time but on click. But the "submenus" (now I understand what several ctx menu means) appears/disappear on hovering. When a user click somewhere, if a ctx menu is visible on the screen, it will naturally disappear because the user is doing something else. If the ctx menu is hiding something behind it, and the user would like to make the ctx menu disappear, well yes, the user must click anywhere on the screen.
  2. Jonas Eberle commented on patch set 8 V +1 11/28/21, 11:03

    I can sense a little improvement here in that closing is a little more consistent now (at least if your cursor stays inside the current panel; see below). I agree with Rachel that a menu should not close at all if the mouse cursor leaves it. It should rather close when any action (click, drag, ...) is performed somewhere else. That is true for the List module dropdown which has better UX in my opinion. The remaining inconsistency for all menus/overlays is that performing an action in another panel (e.g. vs. topbar/page tree/module panel) does not close them. I think ultimately we need to handle calling any actions through a global service object.

    ContextMenu.ts:143

    *at* the bottom
  3. Andreas Kienast commented on patch set 8 11/28/21, 12:58

    Alright. Let's focus on fixing the current flaws down to v10. Feel free to overhaul the ctx menu component afterwards.

    ContextMenu.ts:143 Reply

    Ack
  4. Andreas Kienast uploaded patch set 9 11/28/21, 12:59

  5. core-ci voted on patch set 9 V +1 11/28/21, 13:12 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/19931

  6. Christian Kuhn commented on patch set 9 11/28/21, 13:24

    Tested around on that patch and found a minor glitch with sub menus - I'm sure Andy will figure something out. Other than that, the bugfix is fine from testing point of view and I think we should get it done.
  7. Andreas Kienast uploaded patch set 10 11/28/21, 13:33

  8. Rachel Foucard commented on patch set 10 11/28/21, 13:43

    Reply

    Done
  9. core-ci voted on patch set 10 V +1 11/28/21, 13:46 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/19935

  10. Christian Kuhn voted on patch set 10 V +1 11/28/21, 13:59

  11. Jonas Eberle commented on patch set 10 V +1 CR +1 11/28/21, 15:23

    I haven't noticed the 10.4/11.5/master before, sorry. +1 for the DebounceEvent.
  12. Benni Mack commented on patch set 10 11/28/21, 20:49

    Would only put this to 11.5 + master
  13. Andreas Kienast commented on patch set 10 11/28/21, 21:06

    Reply

    The previous patch (see "Related") was also backported to 10.4, that's why I aim to backport this one as well. I you're strictly against it, I'll adjust the "Releases" line and remove v10.
  14. Andreas Kienast updated the commit message in patch set 11 11/29/21, 08:16

  15. core-ci voted on patch set 11 V +1 11/29/21, 08:26 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/19963

  16. Jonas Eberle voted on patch set 11 V +1 CR +1 11/29/21, 09:21

  17. Benni Mack wrote 11/29/21, 10:22

    Change destination moved from master to main
  18. Benni Mack updated the commit message in patch set 12 11/29/21, 10:23

  19. Jonas Eberle voted on patch set 12 V +1 CR +1 11/29/21, 10:24

  20. Andreas Kienast rebased onto patch set 13 12/03/21, 12:13

  21. Christian Kuhn voted on patch set 13 V +1 CR +1 12/03/21, 12:33

  22. core-ci voted on patch set 13 V +1 12/03/21, 12:33 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/20481

  23. Benni Mack voted on patch set 13 V +1 CR +1 12/03/21, 16:11

  24. Andreas Kienast voted on patch set 13 V +2 CR +2 12/03/21, 16:47

  25. Andreas Kienast merged patch set 14 12/03/21, 16:47