Skip to content

Commit 31949c3

Browse files
committed
fix(NcPopover): use transitionend to wait for popover show/hide animation end
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
1 parent 8c997ce commit 31949c3

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

src/components/NcPopover/NcPopover.vue

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@ export default {
238238
data() {
239239
return {
240240
internalShown: this.shown,
241-
animationDuration: 100,
242241
}
243242
},
244243
@@ -254,7 +253,6 @@ export default {
254253
255254
mounted() {
256255
this.checkTriggerA11y()
257-
this.animationDuration = parseInt(getComputedStyle(this.$el).getPropertyValue('--animation-quick')) || 100
258256
},
259257
260258
beforeDestroy() {
@@ -380,33 +378,37 @@ export default {
380378
},
381379
382380
async afterShow() {
381+
this.getPopoverContentElement().addEventListener('transitionend', () => {
382+
/**
383+
* Triggered after the tooltip was visually displayed.
384+
*
385+
* This is different from the 'show' and 'apply-show' which
386+
* run earlier than this where there is no guarantee that the
387+
* tooltip is already visible and in the DOM.
388+
*/
389+
this.$emit('after-show')
390+
}, { once: true, passive: true })
391+
383392
this.removeFloatingVueAriaDescribedBy()
384393
385394
await this.$nextTick()
386395
await this.useFocusTrap()
387396
this.addEscapeStopPropagation()
388-
389-
setTimeout(() => {
390-
/**
391-
* Triggered after the tooltip was visually displayed.
392-
*
393-
* This is different from the 'show' and 'apply-show' which
394-
* run earlier than this where there is no guarantee that the
395-
* tooltip is already visible and in the DOM.
396-
*/
397-
this.$emit('after-show')
398-
}, this.animationDuration)
399397
},
400-
async afterHide() {
401-
this.clearFocusTrap()
402-
this.clearEscapeStopPropagation()
403-
404-
setTimeout(() => {
398+
afterHide() {
399+
this.getPopoverContentElement().addEventListener('transitionend', () => {
405400
/**
406401
* Triggered after the tooltip was visually hidden.
402+
*
403+
* This is different from the 'hide' and 'apply-hide' which
404+
* run earlier than this where there is no guarantee that the
405+
* tooltip is already visible and in the DOM.
407406
*/
408407
this.$emit('after-hide')
409-
}, this.animationDuration)
408+
}, { once: true, passive: true })
409+
410+
this.clearFocusTrap()
411+
this.clearEscapeStopPropagation()
410412
},
411413
},
412414
}

0 commit comments

Comments
 (0)