[SF][DataPicker] - DataPicker's internal validation reset valueState unexpectedly
See original GitHub issueBug Description
The DatePicker component has built-in validation (https://github.com/SAP/ui5-webcomponents/blob/master/packages/main/src/DatePicker.js#L502). Each time the value is changed, the built-in validation is done and if it pass and original valueState
is Error
, it changes the valueState
to None
.
For some reason, we have some complex validation logic that is triggered when the value is changed and we don’t set minDate
and maxDate
. valueState
and valueStateMessage
are set based on the validation result.
Expected Behavior
valueState
is only determined by the caller of DatePicker and should not be changed internally
Steps to Reproduce
- Go to https://codesandbox.io/s/ui5-webcomponents-forked-4bndy?file=/index.html
- Pick a date not later than today
- DatePicker’s valueState should be kept as
Error
but it’s changed toNone
Isolated Example
https://codesandbox.io/s/ui5-webcomponents-forked-4bndy?file=/index.html
Context
- UI5 Web Components version: 0.31.12
- OS/Platform: macOS
- Browser: Chrome
- Affected component: DatePicker
Priority
- Low
- Medium
- High
- Very High
Stakeholder Info (if applicable)
- Organization: SuccessFactors
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:11 (7 by maintainers)
Top Results From Across the Web
No results found
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@fifoosid
You are still missing the point. I probably explained myself poorly.
The problem is that you are overriding the value-state prop of the datepicker internally. This makes Databinding impossible.
Nobody can bind any data to the datepicker’s value-state prop if the datepicker changes that prop on its own, when a date is selected.
Yes I know that I can get a dom ref to the datepicker and manually set the value state to ‘Whatever’, but at this point I’m back in 2004 writing jquery applications.
People want to bind their pure data models to props on ui components. And those ui components had better not mutate those props on their own, otherwise we can all forget about databinding.
The same issue has now been reported by another user: issue #3571
@phipsalabim Thanks, this is exactly what I mean. The value state should be determined by the consumer of DatePicker component instead of DatePicker itself.
@fifoosid I hope it’s clear now.