mirror of
https://github.com/nextui-org/nextui.git
synced 2025-12-08 19:26:11 +00:00
fix(date-picker): error state (#5317)
* fix(date-range-picker): fixed the error state in preset * Update giant-sloths-shop.md * Removed if statement * chore(date-picker): prettier --------- Co-authored-by: WK Wong <wingkwong.code@gmail.com>
This commit is contained in:
parent
2cbc68965f
commit
d40c744f46
5
.changeset/giant-sloths-shop.md
Normal file
5
.changeset/giant-sloths-shop.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"@heroui/date-picker": patch
|
||||
---
|
||||
|
||||
fix date-range-picker error state (#5309)
|
||||
@ -14,7 +14,7 @@ import type {DateRangePickerSlots, SlotsToClasses} from "@heroui/theme";
|
||||
import type {DateInputProps} from "@heroui/date-input";
|
||||
|
||||
import {useLabelPlacement, useProviderContext} from "@heroui/system";
|
||||
import {useMemo, useRef} from "react";
|
||||
import {useMemo, useRef, useEffect} from "react";
|
||||
import {useDateRangePickerState} from "@react-stately/datepicker";
|
||||
import {useDateRangePicker as useAriaDateRangePicker} from "@react-aria/datepicker";
|
||||
import {clsx, dataAttr, objectToDeps} from "@heroui/shared-utils";
|
||||
@ -125,6 +125,13 @@ export function useDateRangePicker<T extends DateValue>({
|
||||
isInvalid: isAriaInvalid,
|
||||
} = useAriaDateRangePicker({...originalProps, validationBehavior}, state, domRef);
|
||||
|
||||
// Force revalidation when value changes programmatically
|
||||
useEffect(() => {
|
||||
// Trigger revalidation to sync React Aria's internal validation state
|
||||
// with the new programmatically set value
|
||||
state.commitValidation();
|
||||
}, [state.value, state.commitValidation]);
|
||||
|
||||
const isInvalid = isInvalidProp || isAriaInvalid;
|
||||
|
||||
const slots = useMemo(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user