Refactor #4953 - For SplitButton

pull/5206/head
mertsincan 2024-02-02 15:47:58 +00:00
parent ae45937af5
commit 784f7d943e
1 changed files with 10 additions and 5 deletions

View File

@ -33,7 +33,7 @@
:disabled="disabled" :disabled="disabled"
aria-haspopup="true" aria-haspopup="true"
:aria-expanded="isExpanded" :aria-expanded="isExpanded"
:aria-controls="ariaId + '_overlay'" :aria-controls="id + '_overlay'"
@click="onDropdownButtonClick" @click="onDropdownButtonClick"
@keydown="onDropdownKeydown" @keydown="onDropdownKeydown"
:severity="severity" :severity="severity"
@ -50,7 +50,7 @@
</slot> </slot>
</template> </template>
</PVSButton> </PVSButton>
<PVSMenu ref="menu" :id="ariaId + '_overlay'" :model="model" :popup="true" :autoZIndex="autoZIndex" :baseZIndex="baseZIndex" :appendTo="appendTo" :unstyled="unstyled" :pt="ptm('menu')"> <PVSMenu ref="menu" :id="id + '_overlay'" :model="model" :popup="true" :autoZIndex="autoZIndex" :baseZIndex="baseZIndex" :appendTo="appendTo" :unstyled="unstyled" :pt="ptm('menu')">
<template v-if="$slots.menuitemicon" #itemicon="slotProps"> <template v-if="$slots.menuitemicon" #itemicon="slotProps">
<slot name="menuitemicon" :item="slotProps.item" :class="slotProps.class" /> <slot name="menuitemicon" :item="slotProps.item" :class="slotProps.class" />
</template> </template>
@ -74,10 +74,18 @@ export default {
emits: ['click'], emits: ['click'],
data() { data() {
return { return {
id: this.$attrs.id,
isExpanded: false isExpanded: false
}; };
}, },
watch: {
'$attrs.id': function (newValue) {
this.id = newValue || UniqueComponentId();
}
},
mounted() { mounted() {
this.id = this.id || UniqueComponentId();
this.$watch('$refs.menu.visible', (newValue) => { this.$watch('$refs.menu.visible', (newValue) => {
this.isExpanded = newValue; this.isExpanded = newValue;
}); });
@ -106,9 +114,6 @@ export default {
} }
}, },
computed: { computed: {
ariaId() {
return UniqueComponentId();
},
containerClass() { containerClass() {
return [this.cx('root'), this.class]; return [this.cx('root'), this.class];
} }