Skip to content

Commit

Permalink
fix(data-picker): change to id from groupProps not override id from f…
Browse files Browse the repository at this point in the history
…ield context

changes the way the id is handled internally so that the id that comes from the useDatePicker hook
does not overwrite the one that comes from the field context or externally. Instead, the hook will
receive these other ids for correct operation

fix #2039 for dataPicker
  • Loading branch information
lafray committed Nov 6, 2024
1 parent 1c78e6f commit dc00550
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/shoreline/src/components/date-picker/date-picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,16 @@ export function DatePicker<T extends DateValue>(props: DatePickerProps<T>) {
const state = useDatePickerState(domProps)
const ref = useRef(null)
const anchorRef = useRef<HTMLDivElement>(null)
const { groupProps, labelProps, fieldProps, buttonProps, calendarProps } =
useDatePicker(domProps, state, ref)

const store = useFieldContext()
const { id: contextId, error: contextError } = useStore(store, (s) => s)

const id = defaultId || contextId
const error = defaultError || contextError

const { groupProps, labelProps, fieldProps, buttonProps, calendarProps } =
useDatePicker({ ...domProps, id }, state, ref)

return (
<PopoverProvider
open={state.isOpen}
Expand Down

0 comments on commit dc00550

Please sign in to comment.