-
Notifications
You must be signed in to change notification settings - Fork 88
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
Use the popover component for the avatar menu #831
Use the popover component for the avatar menu #831
Conversation
9c42090
to
b79d7c6
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Ping @ma12-co :) |
@ma12-co 🏓 |
e37a861
to
70520ea
Compare
Pong! |
src/components/Avatar/Avatar.vue
Outdated
import { generateUrl } from '@nextcloud/router' | ||
import Tooltip from '../../directives/Tooltip' | ||
import usernameToColor from '../../functions/usernameToColor' | ||
import { userStatus } from '../../mixins' | ||
import Popover from '../Popover/Popover' | ||
import PopoverMenuItem from '../PopoverMenu/PopoverMenuItem' |
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.
Not sure we want to keep this PopoverMenuItem component. What about Actions?
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.
Ideally yes! Followup?
This should actually fix many placement bugs for now
@ma12-co rebase? |
Okay, I found the culprit: when clicking, first the popover will open with an empty contents because at this time the contacts menu is not loaded yet. Only then once loaded, it will render into the contents which triggers a resize. Next up: to find a way to not display the popover while loading. |
It's worse: even if I numb "toggleMenu", it seems the click on the trigger will still trigger the v-tooltip, even though "VPopover" has "open=false". So it seems more work is needed here to get all this under control and avoid redundancy. |
VPopover is always visible even when "open" is false. This fix makes it hidden visually off screen instead. Solves issues with flying arrows when opening and closing some action menus. Signed-off-by: Vincent Petry <vincent@nextcloud.com>
Signed-off-by: Vincent Petry <vincent@nextcloud.com>
Okay, so I managed to fix the flying arrow issue from #1610 by making the popover invisible until "open" is actually true. While this works for the call view popover like in #1610, it doesn't help with the avatar menu The problem with the avatar menu it seems to be that whenever the menu is loaded and "open" is set to true, the v-tooltip will already render the contents, but in the wrong location. And this triggers the resize handler which will put the tooltip at the correct position. So next would be to try to find a way to pre-render the tooltip offscreen while opening the first time, and then letter popper reposition it... The interesting thing now is that opening the menu will now always show it shifted first. Even when reopening. Before these changes it would only do so on the first open. Needs further research... 🤯 |
Thanks for taking over @PVince81 :) |
I've tried to add a loading spinner "fake menu entry" to make sure we got some initial contents in the tooltip. This approach makes it possible for the tooltip to be directly positioned in the right place. Then when the single menu entry loads it doesn't move. Yet another approach I found (without loading spinner) was to add an additional delay before actually showing the tooltip, to let the libraries time to recompute its position before it actually becomes visible. Basically a delay between setting |
Whenever the popover is set to "open" first, if the contents hasn't already been populated in the current tick, the popover's position will appear in the wrong location. Then, directly in the next tick its position is corrected based on the newly appeared content. To avoid the visual glitch we first keep it with "visibility: hidden" upon opening, and then display it once its position has been calculated. Signed-off-by: Vincent Petry <vincent@nextcloud.com>
Ok, the fix is in with "visibility: hidden" with a delay. I've also added a loading spinner on the trigger, which lets the user know that something is loading so that the UI doesn't feel sluggish while loading the menu. Now while the avatar menus work fine now, there's still a problem with the popover from the call view: when you click the actions menu at the bottom, the popover does appear and causes a scrollbar glitch. It seems the "__hidden" class is not enough and needs to be applied on the popover element itself instead. |
When initially hiding the popover during size / position calculation, we need to override the popover's initial visibility and position to avoid glitches like scrollbars appearing. Once the correct position has been calculated by v-tooltip/popper, we can remove the strong hiding class. Signed-off-by: Vincent Petry <vincent@nextcloud.com>
Okay, all works now... Tested with Talk:
@ma12-co can you test and review ? |
I know, the hack is ugly but that's the only way I found to work around the fact that the library will display the tooltip first before repositioning, instead of showing it off screen, evaluating the size, and then repositioning. Maybe there are better ways that would require patching the libs. I saw there will be new versions of the libs (v-tooltip and popper.js), something to look into separately. |
Now a question is still in the air: why use the Popover directly and not use Actions instead ? The latter already has keyboard navigation and everything needed to make it accessible 🤔 |
I had a quick try with Actions and it comes with additional challenges, and the hack for preventing the repositioning glitch doesn't work there: #1670 |
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, cannot approve as I'm the original author 😅
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.
Minor remarks, looks good otherwise 👍
Crap, I retested this and I still see the position shifting glitch from time to time... Might be a race against v-tooltip's timers... Eventually we'll need to look into upgrading v-tooltip/popper.js, maybe patching it to make it work properly... |
Signed-off-by: Vincent Petry <vincent@nextcloud.com>
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.
Approving on behalf of @ma12-co
regression: #1681 |
Signed-off-by: Marco Ambrosini marcoambrosini@pm.me
fix nextcloud/server#18634