Skip to content

Commit 510a7dd

Browse files
authoredFeb 21, 2023
Get rid of dupe id in DatePicker/useDatePicker (adobe#4085)
* Getting rid of duplicated id present in presentational element * generate a separate id instead to avoid useField complaining in useDateField a date field in a datepicker/rangepicker gets the field props removed from it, but we still need to call useField in useDateField which will complain that there isnt a aria labelledby so we still need to pass the field props
1 parent 6e30b87 commit 510a7dd

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed
 

‎packages/@react-aria/datepicker/src/useDatePicker.ts

+2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export interface DatePickerAria {
5353
export function useDatePicker<T extends DateValue>(props: AriaDatePickerProps<T>, state: DatePickerState, ref: RefObject<Element>): DatePickerAria {
5454
let buttonId = useId();
5555
let dialogId = useId();
56+
let fieldId = useId();
5657
let stringFormatter = useLocalizedStringFormatter(intlMessages);
5758

5859
let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({
@@ -113,6 +114,7 @@ export function useDatePicker<T extends DateValue>(props: AriaDatePickerProps<T>
113114
},
114115
fieldProps: {
115116
...fieldProps,
117+
id: fieldId,
116118
[roleSymbol]: 'presentation',
117119
'aria-describedby': ariaDescribedBy,
118120
value: state.value,

0 commit comments

Comments
 (0)
Failed to load comments.