Skip to content

Commit

Permalink
Get rid of dupe id in DatePicker/useDatePicker (#4085)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
LFDanLu authored Feb 21, 2023
1 parent 6e30b87 commit 510a7dd
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/@react-aria/datepicker/src/useDatePicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export interface DatePickerAria {
export function useDatePicker<T extends DateValue>(props: AriaDatePickerProps<T>, state: DatePickerState, ref: RefObject<Element>): DatePickerAria {
let buttonId = useId();
let dialogId = useId();
let fieldId = useId();
let stringFormatter = useLocalizedStringFormatter(intlMessages);

let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({
Expand Down Expand Up @@ -113,6 +114,7 @@ export function useDatePicker<T extends DateValue>(props: AriaDatePickerProps<T>
},
fieldProps: {
...fieldProps,
id: fieldId,
[roleSymbol]: 'presentation',
'aria-describedby': ariaDescribedBy,
value: state.value,
Expand Down

1 comment on commit 510a7dd

@rspbot
Copy link

@rspbot rspbot commented on 510a7dd Feb 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.