Skip to content

Commit

Permalink
fix(cdr-popover): fix popover focus bug. Fix open state bug in example
Browse files Browse the repository at this point in the history
Add 50ms timeout for setting focus. Add event handler on the close event for the popover with custom
trigger

CDR-2377
  • Loading branch information
Kenji Crosland committed Apr 27, 2022
1 parent b3fbac3 commit 1891bc4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/components/popover/CdrPopover.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export default {
this.lastActive = activeElement;
this.isOpen = true;
this.$emit('opened', e);
this.$nextTick(() => {
setTimeout(() => {
const tabbables = tabbable(this.$refs.popup.$el);
if (tabbables[0]) tabbables[0].focus();
});
Expand Down
6 changes: 5 additions & 1 deletion src/components/popover/examples/Popover.vue
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
content-class="popover-override"
id="popover-custom-test"
@opened="popupHandler"
@closed="popupHandler"
@closed="closedCustomHandler"
>
<cdr-text>
This is an example of a popover where the trigger is not passed into the component
Expand Down Expand Up @@ -157,6 +157,10 @@ export default {
popupHandler(e) {
console.log(e);
},
closedCustomHandler(e) {
this.open = false;
console.log(e);
},
},
};
</script>
Expand Down

0 comments on commit 1891bc4

Please sign in to comment.