Skip to content
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

Merged
merged 2 commits into from
Jan 3, 2018

Conversation

danxuliu
Copy link
Member

@danxuliu danxuliu commented Jan 3, 2018

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, the open 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 the open 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 of click (like for other menus in the server). Although the technique has the same problems described in #7613 the propagation of mouseup events is not stopped in the user settings elements, so the problems in this case are just theoretical and do not appear in practice.

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>
@danxuliu danxuliu added 3. to review Waiting for reviews bug feature: users and groups papercut Annoying recurring issue with possibly simple fix. regression labels Jan 3, 2018
@danxuliu danxuliu added this to the Nextcloud 13 milestone Jan 3, 2018
"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>
@danxuliu danxuliu added 2. developing Work in progress and removed 3. to review Waiting for reviews labels Jan 3, 2018
@danxuliu
Copy link
Member Author

danxuliu commented Jan 3, 2018

I have realized that listening to mouseup events on the document instead of listening to click events could mitigate the problem of not closing the menu depending on the element clicked on.

Please do not review yet, and sorry for the noise :-)

@codecov
Copy link

codecov bot commented Jan 3, 2018

Codecov Report

Merging #7668 into master will increase coverage by <.01%.
The diff coverage is n/a.

@@             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
Impacted Files Coverage Δ Complexity Δ
lib/private/Security/CertificateManager.php 91.08% <0%> (-1%) 39% <0%> (ø)
core/js/js.js 65.88% <0%> (ø) 0% <0%> (ø) ⬇️
lib/private/Template/JSConfigHelper.php 0% <0%> (ø) 18% <0%> (+1%) ⬆️
apps/files_trashbin/templates/index.php 0% <0%> (ø) 0% <0%> (ø) ⬇️
apps/files/templates/list.php 0% <0%> (ø) 0% <0%> (ø) ⬇️
...leware/Security/PasswordConfirmationMiddleware.php 82.35% <0%> (ø) 6% <0%> (?)
lib/private/Server.php 81.55% <0%> (+0.11%) 134% <0%> (ø) ⬇️
...e/AppFramework/DependencyInjection/DIContainer.php 78.6% <0%> (+0.77%) 27% <0%> (ø) ⬇️
...amework/Middleware/Security/SecurityMiddleware.php 80.26% <0%> (+2.48%) 25% <0%> (-2%) ⬇️
...ware/Security/Exceptions/NotConfirmedException.php 100% <0%> (+100%) 1% <0%> (ø) ⬇️

@danxuliu danxuliu added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Jan 3, 2018
@MorrisJobke MorrisJobke mentioned this pull request Jan 3, 2018
30 tasks
@danxuliu
Copy link
Member Author

danxuliu commented Jan 3, 2018

Done; this pull request is ready for review!

Copy link
Member

@rullzer rullzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hacky... but sure 🐘

Copy link
Member

@MorrisJobke MorrisJobke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and works 👍

@MorrisJobke MorrisJobke merged commit fa34b53 into master Jan 3, 2018
@MorrisJobke MorrisJobke deleted the fix-popover-menu-not-closing-in-user-settings branch January 3, 2018 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews bug feature: users and groups papercut Annoying recurring issue with possibly simple fix. regression
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants