-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix popover menu not closing in user settings #7668
Fix popover menu not closing in user settings #7668
Conversation
A popover menu is displayed when its element has the "open" CSS class. That class is added when clicking on the menu toggle, but it was removed only when clicking again on the toggle, so the popover menu in user settings could be closed only by clicking again on the menu toggle. Now the "open" CSS class is removed too when clicking on the body, either directly or through event propagation. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
"click" events are handled by several elements in user settings, and some of them (like the edit icon in the user name) stop the propagation of the event. Due to this the event never reaches the document and thus the menu was not closed in those cases. "click" events are always preceded by "mouseup" events (as "click" events are generated when "mousedown" and "mouseup" events occur in the same element), so now the menu is closed when a "mouseup" is received in the document. The described problem would happen too if an element stopped the propagation of the "mouseup" event; currently no element does that in the user settings, so now the menu is always closed as expected. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
I have realized that listening to Please do not review yet, and sorry for the noise :-) |
Codecov Report
@@ Coverage Diff @@
## master #7668 +/- ##
===========================================
+ Coverage 51.19% 51.2% +<.01%
- Complexity 24888 24893 +5
===========================================
Files 1601 1602 +1
Lines 94775 94803 +28
Branches 1371 1372 +1
===========================================
+ Hits 48522 48543 +21
- Misses 46253 46260 +7
|
Done; this pull request is ready for review! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hacky... but sure 🐘
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and works 👍
Fixes (partially; the position part is not covered here) #7617
This pull request fixes a regression introduced in commit 7fb3292
Before that commit the popover menu in user settings was shown or not based on whether the popover menu element was descendant of an active row or not. The
active
CSS class was added to the row when clicking on the menu toggle and removed when clicking again on the menu toggle or on the body, either directly or through event propagation.The aforementioned commit unified its behaviour with the guidelines, which is showing it when the popover menu element has the
open
CSS class. However, theopen
CSS class was removed only when clicking again on the menu toggle and not when clicking on the body, so once open it was not closed until the menu toggle was clicked again. This is fixed by removing theopen
CSS class too when clicking on the body.Note that this pull request restores the same technique used to close the menu when it was based on the active row, and that technique has the same problems described in #7613 (for example, if clicking on the button to edit the user name the popover menu is not closed, because the event propagation is stopped and it never reaches the body element).This pull request restores the same technique used to close the menu when it was based on the active row, although now
mouseup
is used instead ofclick
(like for other menus in the server). Although the technique has the same problems described in #7613 the propagation ofmouseup
events is not stopped in the user settings elements, so the problems in this case are just theoretical and do not appear in practice.