This repository was archived by the owner on May 1, 2025. It is now read-only.
Move Dropdown keydown listener to select element#438
Merged
lucaswerkmeister merged 2 commits intomasterfrom Jun 29, 2021
Merged
Move Dropdown keydown listener to select element#438lucaswerkmeister merged 2 commits intomasterfrom
lucaswerkmeister merged 2 commits intomasterfrom
Conversation
This event listener shouldn’t be called for events bubbling up from the label (including any components in the suffix slot). Bug: T277762
Member
Author
|
Alternative fix that I decided against: diff --git a/vue-components/src/components/Popover.vue b/vue-components/src/components/Popover.vue
index 6f6a234..2bccf6c 100644
--- a/vue-components/src/components/Popover.vue
+++ b/vue-components/src/components/Popover.vue
@@ -6,7 +6,7 @@
@mouseleave="endHover"
v-detect-click-outside="clickOutsideHandler"
>
- <span class="wikit-Popover__target" @click="onTargetClick">
+ <span class="wikit-Popover__target" @click="onTargetClick" @keydown="onTargetKeydown">
<!-- @slot Target should always be a button, as we will listen to its click and hover events -->
<slot name="target" />
</span>
@@ -99,6 +99,13 @@ export default Vue.extend( {
onTargetClick(): void {
this.changeContentVisibility( true );
},
+ onTargetKeydown( event: Event ): void {
+ if ( event.key === 'Enter' ) {
+ // visibility will be changed by associated click event,
+ // just stop this one from bubbling out of the component
+ event.stopPropagation();
+ }
+ },
startHover(): void {
if ( !this.reactToHover ) {
return; |
sai-san
approved these changes
Jun 28, 2021
Contributor
sai-san
left a comment
There was a problem hiding this comment.
LGTM 💯 I tested the changes locally and the fix seems to have corrected the unwanted beaviour. Thank you Lucas!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This event listener shouldn’t be called for events bubbling up from the label (including any components in the suffix slot).
Bug: T277762
Tested with the following storybook patch: