ui5-webcomponents
ui5-webcomponents copied to clipboard
fix(framework): fix handling of 'null' set to str props
Issue Setting "null" is set to property from type String leads to strange and incorrect state
Example:
(1) Input has value property:
@property()
value!: string
(2) When we set the property to null:
input.value = null;
(3) we pass "null" lit-html template, that wraps it with ifDefined directive, that treats null as "nothing", and as a result lit-html sets the property to undefined (via this code).
Current behaviour After the 1,2,3 steps are done, the state is:
- the native input of the Input component shows "undefined" in the input field
- the Input component'value property is null
- the Input component'value attr is not updated (shows the previously set value)
Behaviour with this change With this change, we add validation and fallback to empty string in case of setting "null". So, in the same case, the state is:
- the value in the native input will be cleared
- the Input component'value property is empty string
- the Input component'value attr is updated to empty string.