primereact
primereact copied to clipboard
Calendar: Changing a value removes the entire value
Describe the bug
Enter any valid date to the first input (for example 11/22/1999). Move to the 2nd input and enter any valid date (you can use same date for example). Move back to the first input and try to edit date - for example change year from 1999 to 1998. Pay attention that as soon as you remove the last digit, the value will be cleared. In the 2nd input you can navigate cursor through the date and change it as you need and value will not be cleared.
Reproducer
https://codesandbox.io/s/reverent-breeze-9guo7x
PrimeReact version
8.1.1
React version
17.x
Language
ALL
Build / Runtime
Create React App (CRA)
Browser(s)
No response
Steps to reproduce the behavior
No response
Expected behavior
No response
@melloware This seem to be fixed as of latest master branch.
Can this be closed?
@STIAANWOL I am still seeing the same result with 8.3.0? https://codesandbox.io/s/vibrant-zeh-f8kexq?file=/src/demo/CalendarDemo.js
If you follow the instructions exactly it is still happening?
@melloware
I pulled master branch.
Ran command 'next dev'
And tested this issue.
Can confirm the behaviour is as OP wanted it to be. (on latest master)
Oh yeah let me try that!
Ahh @STIAANWOL the real bug is when you add mask="99/99/9999" showOnFocus={false}
.
Add that to the Icon example in the showcase and you will see the same behavior described.
@melloware Ah great thank you. I know what the bug is now. Can reproduce.
I would like to have a go at fixing it today.
Couldnt find anything just yet.
It does look like the issue has to do with showOnFocus={false}
though.
Following OP's instructions with only mask="99/99/9999"
on the calendar does not result in the bug.
The bug will occur if you follow OP's instructions, have showOnFocus={false}
on the Calendar AND the overlay is NOT showing.
The bug will not occur if you follow OP's instructions but focus the icon calendar by clicking on the ICON itself, have showOnFocus={false}
on the Calendar AND the overlay IS showing.
See below:
I think you nailed it. Any help would be appreciated!
Ahh @STIAANWOL the real bug is when you add
mask="99/99/9999" showOnFocus={false}
.Add that to the Icon example in the showcase and you will see the same behavior described.
mask + shoOnFocus off + default value as anything other than null will trigger this issue, apparently.
Any update here?
OK I just tested this with source code in main for 8.7.2 and by adding keepInvalid
to the Calendar this bug is fixed. This allows when you remove that last digit it doesn't erase the calendar it leaves the invalid value in there for you to fill out.
<Calendar id="icon" value={date3} dateFormat="mm/dd/yy" mask="99/99/9999" keepInvalid showOnFocus={false} onChange={(e) => setDate3(e.value)} showIcon />
8.7.2 is out if you guys want to try my solution above.