diff --git a/resources/js/components/fieldtypes/CheckboxesFieldtype.vue b/resources/js/components/fieldtypes/CheckboxesFieldtype.vue index 50293c191e9..b6503d18e6d 100644 --- a/resources/js/components/fieldtypes/CheckboxesFieldtype.vue +++ b/resources/js/components/fieldtypes/CheckboxesFieldtype.vue @@ -4,6 +4,7 @@ -import { CheckboxIndicator, CheckboxRoot, useId } from 'reka-ui'; -import { computed, useAttrs } from 'vue'; +import { CheckboxIndicator, CheckboxRoot } from 'reka-ui'; +import { computed, useAttrs, useId } from 'vue'; import { cva } from 'cva'; import { twMerge } from 'tailwind-merge'; import { injectCheckboxContext } from './Group.vue'; @@ -10,6 +10,8 @@ defineOptions({ inheritAttrs: false }); const attrs = useAttrs(); const props = defineProps({ + /** Optional ID for the checkbox input */ + id: { type: String, default: () => useId() }, /** Controls the vertical alignment of the checkbox with its label. Options: `start`, `center` */ align: { type: String, default: 'start', validator: (value) => ['start', 'center'].includes(value) }, /** Description text to display below the label */ @@ -37,8 +39,6 @@ const emit = defineEmits(['update:modelValue', 'keydown']); const { appearance } = injectCheckboxContext() ?? { appearance: computed(() => 'default') }; -const id = useId(); - const handleKeydown = (event) => { emit('keydown', event); @@ -97,7 +97,7 @@ const conditionalProps = computed(() => { // Only add aria-describedby if description exists AND it's not a solo checkbox if (props.description && !props.solo) { - props_obj['aria-describedby'] = `${id}-description`; + props_obj['aria-describedby'] = `${props.id}-description`; } if (props.solo && (props.label || props.value)) { @@ -112,7 +112,7 @@ const conditionalProps = computed(() => {
{
-
diff --git a/resources/js/components/ui/Radio/Item.vue b/resources/js/components/ui/Radio/Item.vue index 4c97b488145..5f47e260f89 100644 --- a/resources/js/components/ui/Radio/Item.vue +++ b/resources/js/components/ui/Radio/Item.vue @@ -4,6 +4,8 @@ import { RadioGroupIndicator, RadioGroupItem } from 'reka-ui'; import { injectRadioContext } from './Group.vue'; const props = defineProps({ + /** Optional ID for the radio button */ + id: { type: String, default: () => useId() }, /** Description text to display below the label */ description: { type: String, default: null }, disabled: { type: Boolean, default: false }, @@ -15,8 +17,6 @@ const props = defineProps({ }); const { appearance } = injectRadioContext() ?? { appearance: computed(() => 'default') }; - -const id = useId();