Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: improve input value handling #10935

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

chore: improve input value handling #10935

wants to merge 2 commits into from

Conversation

pskelin
Copy link
Contributor

@pskelin pskelin commented Feb 24, 2025

<ui5-input> has a very complex logic for handling type=numeric, implemented by keeping _innerValue.

This has two issues:

  1. a patch is necessary in preact to render a value in the DOM only when it is different from the old value.
  2. this prevents forcing an old value on the input in case an event handler decides not to accept new state

This fix remove the preact patch returning it to default - if a value is set in the tempate, it will be set in the DOM (for native inputs this will always assign a value from the state, even if it is the same)

By removing the _innverValue, apps can automatically set an old value and it will propagate in the DOM.

Example before - an input that accepts only three numbers by setting the old value if more than three numbers arrive

type `123` -> input value is `123`
type `1234` -> input value prop is `123` but input value in dom is `1234`

Example after - when setting an old value, it will be updated in the inner input, so typing 1234 will correctly result in 123 both in .value property and in DOM.

see Input_old_value.html for example code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant