From 784f7d943eeaa174db5123f24b6dc796eccf3f53 Mon Sep 17 00:00:00 2001 From: mertsincan Date: Fri, 2 Feb 2024 15:47:58 +0000 Subject: [PATCH] Refactor #4953 - For SplitButton --- components/lib/splitbutton/SplitButton.vue | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/components/lib/splitbutton/SplitButton.vue b/components/lib/splitbutton/SplitButton.vue index ae3135a792..8901bec964 100755 --- a/components/lib/splitbutton/SplitButton.vue +++ b/components/lib/splitbutton/SplitButton.vue @@ -33,7 +33,7 @@ :disabled="disabled" aria-haspopup="true" :aria-expanded="isExpanded" - :aria-controls="ariaId + '_overlay'" + :aria-controls="id + '_overlay'" @click="onDropdownButtonClick" @keydown="onDropdownKeydown" :severity="severity" @@ -50,7 +50,7 @@ - + @@ -74,10 +74,18 @@ export default { emits: ['click'], data() { return { + id: this.$attrs.id, isExpanded: false }; }, + watch: { + '$attrs.id': function (newValue) { + this.id = newValue || UniqueComponentId(); + } + }, mounted() { + this.id = this.id || UniqueComponentId(); + this.$watch('$refs.menu.visible', (newValue) => { this.isExpanded = newValue; }); @@ -106,9 +114,6 @@ export default { } }, computed: { - ariaId() { - return UniqueComponentId(); - }, containerClass() { return [this.cx('root'), this.class]; }