-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Calendar's controlled value prop (in onChange) and setValue() from CalendarStateContext can't be set to null #6006
Comments
Looks like the same issue as mentioned here: #3187 (comment). I believe that we can just add a if statement before here:
to be something like
Mind opening a PR? |
OK, I'll try to do this task. |
@LFDanLu Please help me understand in which interfaces to add |
I imagine
| null to.
|
UPD:
And also, when I hover over Although in fact, this is what the code looks like:
It seems like it's just not visible And we can also see that my fix is working. This can be viewed in the "Test Instructions" section of my PR. Even on the video that I attached to my PR, it is also clearly visible. |
Oh odd, I'll see if I can take a look soon! |
@LFDanLu Well, thank you! I've put my PR in the draft for now, just in case. |
Provide a general summary of the issue here
I get the
setValue
method fromCalendarStateContext
and try to setnull
as the value forsetValue()
but an error immediately occurs and nothing is set. Prop ofvalue
andonChange
andsetValue(null)
with the wrong type and TS swears atnull
.🤔 Expected Behavior?
Calendar's controlled
value
prop andstate.setValue()
fromCalendarStateContext
and inonChange
prop can be set tonull
😯 Current Behavior
Calendar controlled
value
andsetValue()
fromCalendarStateContext
can't be set tonull
, judging byvalue?:T
, but for some reason it allows you to setnull
.And the same goes for method
setValue()
fromCalendarStateContext
. You cannot setnull
insetValue()
💁 Possible Solution
ValueBase<T, C = T>
:value?: T | null
,onChange?: (value: C (and null))
CalendarState extends CalendarStateBase
:setValue(value: CalendarDate | null): void;
null
so that you can, for example, reset the date in the calendar.🔦 Context
No response
🖥️ Steps to Reproduce
Here you can see an example. You can see that
onChange
andsetValue(null)
with the wrong type and TS swears at null. And if you press the "Clear" button and try to setstate.setValue(null);
and the value in value is not resetVersion
1.1.1 react-aria-components
What browsers are you seeing the problem on?
Chrome
If other, please specify.
No response
What operating system are you using?
MacOS 13.3
🧢 Your Company/Team
No response
🕷 Tracking Issue
No response
The text was updated successfully, but these errors were encountered: