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:
Vishv Salvi 2025-05-27 03:42:32 +05:30 committed by GitHub
parent 2cbc68965f
commit d40c744f46
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 1 deletions

View File

@ -0,0 +1,5 @@
---
"@heroui/date-picker": patch
---
fix date-range-picker error state (#5309)

View File

@ -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(