ContextMenuCloseWatcher #10809
Labels
addition/proposal
New features or enhancements
needs implementer interest
Moving the issue forward requires implementers to express interest
Problem
Due to the fact that the closing operation of the context menu may differ from ordinary close requests (for example, in the Linux Chrome browser, a
pointerdown
event outside of the context menu can trigger the context menu to close, while ordinary close events are triggered byclick
events). Therefore, usingCloseWatcher
class to simulate the context menu would result in the simulated context menu's closing conditions being inconsistent with those of the standard context menu. Such user experience is not ideal.The absence of information regarding "whether the focus should return to the target element" is also one of the reasons why
CloseWatcher
is insufficient(See details below).Solution
Therefore, I propose the addition of a
ContextMenuCloseWatcher
class, which is similar toCloseWatcher
. Below is a simple code demonstration:ContextMenuCloseWatcher
also differs fromCloseWatcher
in one aspect:There is no parameter for the
close
event callback ofCloseWatcher
, while there is one parameter for that ofContextMenuCloseWatcher
:shouldReturnFocus
. If the closing of the context menu is usually accompanied by a change of focus in the document (for example, if the mouse clicks elsewhere), thenshouldReturnFocus
is false; if the change implies that the focus should be returned to the very target element of the context menu (for example, the user presses ESC), thenshouldReturnFocus
is true.The behavior of creating
ContextMenuCloseWatcher
on platforms that do not support context menus is left for further discussion.The text was updated successfully, but these errors were encountered: