Skip to content

Commit

Permalink
feat: added aria props to picker logic
Browse files Browse the repository at this point in the history
  • Loading branch information
logaretm committed Feb 16, 2025
1 parent c318e90 commit 390ca1a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 9 additions & 1 deletion packages/core/src/usePicker/usePicker.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { computed, InjectionKey, provide, ref } from 'vue';
import { computed, InjectionKey, provide, ref, toValue } from 'vue';
import { usePopoverController } from '../helpers/usePopoverController';
import { createDisabledContext } from '../helpers/createDisabledContext';
import { normalizeProps, withRefCapture } from '../utils/common';
Expand All @@ -10,6 +10,11 @@ export interface PickerProps {
* Whether the picker is disabled.
*/
disabled?: boolean;

/**
* The label for the picker.
*/
label: string;
}

export interface PickerContext {
Expand All @@ -30,6 +35,8 @@ export function usePicker(_props: Reactivify<PickerProps>) {
return withRefCapture(
{
role: 'dialog',
'aria-modal': 'true',
'aria-label': toValue(props.label),
},
pickerEl,
);
Expand All @@ -41,6 +48,7 @@ export function usePicker(_props: Reactivify<PickerProps>) {

const pickerTriggerProps = useControlButtonProps(() => {
return {
'aria-label': toValue(props.label),
disabled: disabled.value,
onClick: onOpen,
};
Expand Down
4 changes: 3 additions & 1 deletion packages/playground/src/components/DateField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ const {
direction,
} = useDateTimeField(props);
const { pickerProps, pickerTriggerProps } = usePicker({});
const { pickerProps, pickerTriggerProps } = usePicker({
label: 'Pick a date',
});
</script>

<template>
Expand Down

0 comments on commit 390ca1a

Please sign in to comment.