Skip to content

Commit

Permalink
Try to debug cocs
Browse files Browse the repository at this point in the history
Signed-off-by: Raimund Schlüßler <raimund.schluessler@mailbox.org>
  • Loading branch information
raimund-schluessler committed Aug 16, 2022
1 parent 38cca70 commit 97fbacf
Showing 1 changed file with 21 additions and 34 deletions.
55 changes: 21 additions & 34 deletions src/components/Popover/Popover.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,9 @@ export default {
type: String,
default: '',
},
/**
* Enable popover focus trap
*/
focusTrap: {
type: Boolean,
default: true,
default: false,
},
},
Expand Down Expand Up @@ -145,14 +142,23 @@ export default {
},
beforeDestroy() {
this.clearFocusTrap()
this.afterHide()
},
methods: {
/**
* Add focus trap for accessibility.
*/
useFocusTrap() {
afterShow() {
/**
* Triggered after the tooltip was visually displayed.
*
* This is different from the 'show' and 'apply-show' which
* run earlier than this where there is no guarantee that the
* tooltip is already visible and in the DOM.
*/
this.$emit('after-show')
/**
* Add focus trap for accessibility.
*/
this.$nextTick(() => {
if (!this.focusTrap) {
return
Expand All @@ -173,36 +179,17 @@ export default {
this.$focusTrap.activate()
})
},
/**
* Remove focus trap
*
* @param {object} options The configuration options for focusTrap
*/
async clearFocusTrap(options = {}) {
try {
this.$focusTrap?.deactivate(options)
this.$focusTrap = null
} catch (err) {
console.warn(err)
}
},
afterShow() {
/**
* Triggered after the tooltip was visually displayed.
*
* This is different from the 'show' and 'apply-show' which
* run earlier than this where there is no guarantee that the
* tooltip is already visible and in the DOM.
*/
this.$emit('after-show')
this.useFocusTrap()
},
afterHide() {
/**
* Triggered after the tooltip was visually hidden.
*/
this.$emit('after-hide')
this.clearFocusTrap()
/**
* Remove focus trap
*/
this.$focusTrap?.deactivate()
this.$focusTrap = null
},
},
}
Expand Down

0 comments on commit 97fbacf

Please sign in to comment.