Skip to content
Snippets Groups Projects
Commit 84e99527 authored by Andreas Fernandez's avatar Andreas Fernandez
Browse files

[BUGFIX] Major context menu refinements

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

Resolves: #96105
Related: #94891
Releases: main, 11.5
Change-Id: Ib9c2505480ada166f8497fc69b42fb9ee45f6cc3
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72425


Tested-by: default avatarcore-ci <typo3@b13.com>
Tested-by: default avatarAndreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: default avatarAndreas Fernandez <a.fernandez@scripting-base.de>
parent 726f82c9
No related merge requests found
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment