Open Lukas742 opened 1 year ago
Hello @SAP/ui5-webcomponents-topic-rl @MapTo0 @hristop I am forwarding the request to your ownership.
This started as a common request to several of our web components related to how we handle value state. In some web components we change the value-state internally - StepInput, DatePicker and MultiComboBox. And because it is a public property, sometimes application state gets desynchronised as described in the issue description:
The description is taken from above and speaks about the StepInput, but it was same for the DatePicker, and most likely for the MultiComboBox as it applies to web components that have public valueState property, internally changes the valueState property and do not fire any event for that, and any way to prevent the internal value state handling.
" The StepInput (should keep the "Success" value-state, but since there is no way to prevent the internal validation (setting the value-state internally) and there is no public event developers could register to, it gets kind of tricky without using an observer to detect these changes and then also to adjust the React state accordingly.
With the help of a public custom event (e.g. value-state-change), developers could handle value-state changes in the same way as e.g. value changes. Additionally, it would be great if the event would allow preventing the default behavior (internal value-state changes) by calling event.preventDefault() "
To overcome this, we took the following approach, that has been already implemented in StepInput and DatePicker:
As the MultiComboBox is the only web component left, that internally changes the valueState property and does not notify the consumers and does not allow preventing it, I am forwarding the issue to you for addressing this request.
BR, ilhan
Feature Request Description
In UI5 Web Components for React we're increasingly receiving issues about value-state handling. In React it's common to fully control a component, meaning that you are always aware of its state which is controlled by a React state. E.g.:
https://github.com/SAP/ui5-webcomponents/assets/9749730/e87ee8fe-18ed-45dd-bdd8-203bc4edce95
codeSandbox
Here the
value
of theInput
is controlled by a React state, every time the value is updated by the useronInput
is called and there the React state is updated with the respective value of the input.For the
value-state
this behavior can sometimes not be achieved. As example I'm reusing parts of the codeSandbox provided in this issue.https://github.com/SAP/ui5-webcomponents/assets/9749730/dd3bb279-3bab-4fb1-abd2-16731b24a914
codeSandbox
Here the
StepInput
should keep the "Success" value-state, but since there is no way to prevent the internal validation (setting the value-state internally) and there is no public event developers could register to, it gets kind of tricky without using an observer to detect these changes and then also to adjust the React state accordingly.With the help of a public custom event (e.g.
value-state-change
), developers could handle value-state changes in the same way as e.g.value
changes. Additionally, it would be great if the event would allow preventing the default behavior (internal value-state changes) by callingevent.preventDefault()
Proposed Solution
value-state
changesevent.preventDefault()
in the handler of the new event.Proposed Alternatives
If it's not feasible to implement we will outline this particularity in our documentation.
Organization
UI5 Web Components for React
Additional Context
Example of Issues that would most probably profit or even be fixed by this feature:
4791
Priority
None
Privacy Policy