Skip to content

Fix actions dropdown focus timing - #1761

Merged
ChristophWurst merged 2 commits into
masterfrom
bugfix/1760/fix-popover-initial-focus
Mar 16, 2021
Merged

Fix actions dropdown focus timing#1761
ChristophWurst merged 2 commits into
masterfrom
bugfix/1760/fix-popover-initial-focus

Conversation

@PVince81

Copy link
Copy Markdown
Contributor

Because "@after-show" is still happening too early due to v-tooltip's
use of "requestAnimationFrame" we can't rely on its events to tell us
when the popover is actually visible.

This workaround introduces an additional Popover event "after-show" and
"after-hide" that are based on monitoring the inner "isOpen" property
which is the one toggling the CSS visibility.

The Actions popover logic now uses "after-show" to reliably apply the
focus on the first action element.

Fixes #1760
See Akryum/floating-vue#661 for the upstream issue.

Comment thread src/components/Popover/Popover.vue Outdated
Because "@after-show" is still happening too early due to v-tooltip's
use of "requestAnimationFrame" we can't rely on its events to tell us
when the popover is actually visible.

This workaround introduces an additional Popover event "after-show" and
"after-hide" that are based on monitoring the inner "isOpen" property
which is the one toggling the CSS visibility.

The Actions popover logic now uses "after-show" to reliably apply the
focus on the first action element.

Signed-off-by: Vincent Petry <vincent@nextcloud.com>
@PVince81
PVince81 force-pushed the bugfix/1760/fix-popover-initial-focus branch from aaf88c2 to a3774bc Compare March 12, 2021 15:29
@PVince81

Copy link
Copy Markdown
Contributor Author

tldr; fixes keyboard navigation for after opening the menu 😄

},
(val) => {
if (val) {
this.$emit('after-show')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please document those events

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@PVince81 you can document them for our styleguide directly, no need for a readme :)
https://vue-styleguidist.github.io/docs/Documenting.html#events

@PVince81
PVince81 requested a review from skjnldsv March 15, 2021 14:59
@PVince81

Copy link
Copy Markdown
Contributor Author

@skjnldsv docs added

},
(val) => {
if (val) {
this.$emit('after-show')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@PVince81 you can document them for our styleguide directly, no need for a readme :)
https://vue-styleguidist.github.io/docs/Documenting.html#events

@PVince81
PVince81 requested a review from skjnldsv March 16, 2021 15:57
@PVince81
PVince81 force-pushed the bugfix/1760/fix-popover-initial-focus branch from f5c4b76 to b42b0f4 Compare March 16, 2021 15:57
@PVince81

Copy link
Copy Markdown
Contributor Author

@skjnldsv nice, thanks for the hint. I've reverted the bits in the header and added docs close to $emit. Then squashed into the last commit.

Now it looks like this:
image

Signed-off-by: Vincent Petry <vincent@nextcloud.com>
@PVince81
PVince81 force-pushed the bugfix/1760/fix-popover-initial-focus branch from b42b0f4 to 960e91e Compare March 16, 2021 15:59

@skjnldsv skjnldsv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

giphy

@skjnldsv skjnldsv added 4. to release Ready to be released and/or waiting for tests to finish and removed 3. to review Waiting for reviews labels Mar 16, 2021
@ChristophWurst
ChristophWurst merged commit 3a30081 into master Mar 16, 2021
@ChristophWurst
ChristophWurst deleted the bugfix/1760/fix-popover-initial-focus branch March 16, 2021 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4. to release Ready to be released and/or waiting for tests to finish bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Actions menu autofocus on elements doesn't work initially

4 participants