question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[SF][DataPicker] - DataPicker's internal validation reset valueState unexpectedly

See original GitHub issue

Bug 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

  1. Go to https://codesandbox.io/s/ui5-webcomponents-forked-4bndy?file=/index.html
  2. Pick a date not later than today
  3. DatePicker’s valueState should be kept as Error but it’s changed to None

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:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
phipsalabimcommented, Jul 30, 2021

@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

1reaction
2bno1commented, Jul 27, 2021

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found