Skip to content

Commit

Permalink
fix: 927 dropdown focus reset post selection (#931)
Browse files Browse the repository at this point in the history
* fix: 927 dropdown focus reset post selection

* chore: update story with focus button

Co-authored-by: Lee Chase <lee.chase@uk.ibm.com>
  • Loading branch information
lee-chase and lee-chase authored Jun 23, 2020
1 parent 3fd9208 commit 803d36c
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions packages/core/src/components/cv-dropdown/cv-dropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
:class="{ 'bx--dropdown__wrapper--inline': inline, 'cv-dropdown': !formItem }"
:style="wrapperStyleOverride"
>
<span v-if="label" :id="`${uid}-label`" class="bx--label" :class="{ 'bx--label--disabled': disabled }">{{
label
}}</span>
<span v-if="label" :id="`${uid}-label`" class="bx--label" :class="{ 'bx--label--disabled': disabled }">
{{ label }}
</span>

<div
v-if="!inline && isHelper"
Expand Down Expand Up @@ -65,6 +65,7 @@
:aria-labelledby="ariaLabeledBy"
:disabled="disabled"
type="button"
ref="button"
>
<WarningFilled16 v-if="isInvalid && inline" class="bx--dropdown__invalid-icon" />
<span
Expand Down Expand Up @@ -285,15 +286,15 @@ export default {
},
onEsc() {
this.open = false;
this.$el.focus();
this.focus();
},
onClick(ev) {
if (this.disabled) {
ev.preventDefault();
} else {
this.open = !this.open;
if (!this.open) {
this.$el.focus();
this.focus();
}
let target = ev.target;
Expand All @@ -309,6 +310,11 @@ export default {
}
}
},
focus() {
this.$nextTick(() => {
this.$refs.button.focus();
});
},
},
};
</script>

0 comments on commit 803d36c

Please sign in to comment.