diff --git a/packages/shoreline/src/components/date-picker/date-picker.tsx b/packages/shoreline/src/components/date-picker/date-picker.tsx index 7f23c45a47..8114da12ac 100644 --- a/packages/shoreline/src/components/date-picker/date-picker.tsx +++ b/packages/shoreline/src/components/date-picker/date-picker.tsx @@ -32,8 +32,6 @@ export function DatePicker(props: DatePickerProps) { const state = useDatePickerState(domProps) const ref = useRef(null) const anchorRef = useRef(null) - const { groupProps, labelProps, fieldProps, buttonProps, calendarProps } = - useDatePicker(domProps, state, ref) const store = useFieldContext() const { id: contextId, error: contextError } = useStore(store, (s) => s) @@ -41,6 +39,9 @@ export function DatePicker(props: DatePickerProps) { const id = defaultId || contextId const error = defaultError || contextError + const { groupProps, labelProps, fieldProps, buttonProps, calendarProps } = + useDatePicker({ ...domProps, id }, state, ref) + return ( ( const state = useDateRangePickerState(domProps) const ref = useRef(null) const anchorRef = useRef(null) + + const store = useFieldContext() + const { id: contextId, error: contextError } = useStore(store, (s) => s) + + const id = defaultId || contextId + const error = defaultError || contextError + const { groupProps, labelProps, @@ -35,13 +42,7 @@ export function DateRangePicker( endFieldProps, buttonProps, calendarProps, - } = useDateRangePicker(domProps, state, ref) - - const store = useFieldContext() - const { id: contextId, error: contextError } = useStore(store, (s) => s) - - const id = defaultId || contextId - const error = defaultError || contextError + } = useDateRangePicker({ ...domProps, id }, state, ref) return ( (