Skip to content

Commit

Permalink
fix(NcPopover): a11y attrs provide-inject reactivity
Browse files Browse the repository at this point in the history
Signed-off-by: Grigorii K. Shartsev <me@shgk.me>
  • Loading branch information
ShGKme committed Jan 25, 2024
1 parent 20577bc commit 797084b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
8 changes: 6 additions & 2 deletions src/components/NcButton/NcButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,9 @@ export default {
name: 'NcButton',
inject: {
ncPopoverTriggerAttrs: {
getNcPopoverTriggerAttrs: {
from: 'NcPopover:trigger:attrs',
default: () => ({}),
default: () => () => ({}),
},
},
Expand Down Expand Up @@ -600,6 +600,10 @@ export default {
isReverseAligned() {
return this.alignment.includes('-')
},
ncPopoverTriggerAttrs() {
return this.getNcPopoverTriggerAttrs()
},
},
/**
Expand Down
19 changes: 6 additions & 13 deletions src/components/NcPopover/NcPopover.vue
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,14 @@ See: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/

<template>
<Dropdown ref="popover"
:shown.sync="shownProxy"
:distance="10"
:arrow-padding="10"
v-bind="$attrs"
:no-auto-focus="true /* Handled by the focus trap */"
:popper-class="popoverBaseClass"
:shown="internalShown"
v-on="$listeners"
@update:shown="internalShown = $event"
@apply-show="afterShow"
@apply-hide="afterHide">
<NcPopoverTriggerProvider v-slot="slotProps" :shown="internalShown" :popup-role="popupRole">
Expand Down Expand Up @@ -252,22 +253,14 @@ export default {
}
},
computed: {
shownProxy: {
get() {
return this.shown
},
set(value) {
this.internalShown = value
this.$emit('update:shown', value)
},
},
},
watch: {
shown(value) {
this.internalShown = value
},
internalShown(value) {
this.$emit('update:shown', value)
},
},
mounted() {
Expand Down
4 changes: 2 additions & 2 deletions src/components/NcPopover/NcPopoverTriggerProvider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ export default defineComponent({
provide() {
return {
'NcPopover:trigger:shown': computed(() => this.shown),
'NcPopover:trigger:attrs': computed(() => this.triggerAttrs),
'NcPopover:trigger:shown': () => this.shown,
'NcPopover:trigger:attrs': () => this.triggerAttrs,
}
},
Expand Down

0 comments on commit 797084b

Please sign in to comment.