Skip to content

Commit 0dd5ca5

Browse files
committed
fix: fix disabled prop for ButtonGroup
1 parent 4f2eb61 commit 0dd5ca5

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

adminforth/spa/src/afcl/ButtonGroup.vue

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<template>
2-
<div class="inline-flex rounded-md shadow-xs" role="group">
3-
<button v-for="button in buttons" :key="`${button}-button-controll`" :disabled="slotProps[button]?.disabled"
2+
<div v-if="isInitFinished" class="inline-flex rounded-md shadow-xs" role="group">
3+
<button v-for="button in buttons" :key="`${button}-button-controll`"
4+
:disabled="slotProps[button].disabled"
45
class="inline-flex items-center text-sm font-medium border-t border-b border-r border-lightButtonGroupBorder focus:z-10 focus:ring-2 dark:border-darkButtonGroupBorder disabled:opacity-50 disabled:cursor-not-allowed"
56
:class="[
67
buttonsStyles[button] === 'rounded' ? 'border rounded-lg'
@@ -19,13 +20,13 @@
1920
</template>
2021

2122
<script lang="ts" setup>
22-
import { onMounted, useSlots, ref, type Ref } from 'vue';
23+
import { onMounted, useSlots, reactive, ref, type Ref } from 'vue';
2324
2425
const buttons : Ref<string[]> = ref([]);
2526
const buttonsStyles : Ref<Record<string, string>> = ref({});
2627
const activeButton = ref('');
27-
const slotProps: Record<string, any> = ref({});
28-
28+
const slotProps = reactive<Record<string, any>>({});
29+
const isInitFinished = ref(false);
2930
const emits = defineEmits([
3031
'update:activeButton',
3132
]);
@@ -56,7 +57,11 @@
5657
} else {
5758
slotProps[button] = {};
5859
}
60+
if (slotProps[button]?.disabled === undefined) {
61+
slotProps[button].disabled = false;
62+
}
5963
}
64+
isInitFinished.value = true;
6065
});
6166
6267

0 commit comments

Comments
 (0)