diff --git a/ui/src/formkit/inputs/select/SelectMain.vue b/ui/src/formkit/inputs/select/SelectMain.vue index d50606ca22..71ee100bd2 100644 --- a/ui/src/formkit/inputs/select/SelectMain.vue +++ b/ui/src/formkit/inputs/select/SelectMain.vue @@ -14,6 +14,7 @@ import { watch, type PropType, } from "vue"; +import { isFalse } from "./isFalse"; import SelectContainer from "./SelectContainer.vue"; export interface SelectProps { @@ -238,10 +239,6 @@ const initSelectProps = () => { } }; -const isFalse = (value: string | boolean | undefined | null) => { - return [undefined, null, "false", false].includes(value); -}; - const isLoading = ref(false); const isFetchingMore = ref(false); const page = ref(1); diff --git a/ui/src/formkit/inputs/select/SelectOption.vue b/ui/src/formkit/inputs/select/SelectOption.vue index d09a2d989e..41d248193d 100644 --- a/ui/src/formkit/inputs/select/SelectOption.vue +++ b/ui/src/formkit/inputs/select/SelectOption.vue @@ -4,6 +4,7 @@ import { vScroll } from "@vueuse/components"; import { useEventListener, type UseScrollReturn } from "@vueuse/core"; import { computed, ref, watch } from "vue"; import SelectOptionItem from "./SelectOptionItem.vue"; +import { isFalse } from "./isFalse"; const props = defineProps<{ options: Array & { label: string; value: string }>; @@ -81,7 +82,7 @@ const handleSelected = (index: number) => { } } selectedIndex.value = index; - if (option) { + if (option && !isDisabled(option)) { emit("selected", option); } }; @@ -112,11 +113,15 @@ const reachMaximumLimit = computed(() => { return false; }); -const isDisabled = (option: { label: string; value: string }) => { +const isDisabled = ( + option: Record & { label: string; value: string } +) => { + const attrs = option.attrs as Record; return ( - reachMaximumLimit.value && - selectedValues.value && - !selectedValues.value.includes(option.value) + (reachMaximumLimit.value && + selectedValues.value && + !selectedValues.value.includes(option.value)) || + !isFalse(attrs?.disabled as string | boolean | undefined) ); }; diff --git a/ui/src/formkit/inputs/select/isFalse.ts b/ui/src/formkit/inputs/select/isFalse.ts new file mode 100644 index 0000000000..918ab0811c --- /dev/null +++ b/ui/src/formkit/inputs/select/isFalse.ts @@ -0,0 +1,3 @@ +export const isFalse = (value: string | boolean | undefined | null) => { + return [undefined, null, "false", false].includes(value); +};