Skip to content

Conversation

@Jo-Byr
Copy link
Contributor

@Jo-Byr Jo-Byr commented Aug 14, 2025

Remove update on update:modelValue to fix bug
preventing typing non integer values in TextField

@Jo-Byr Jo-Byr requested a review from jourdain August 14, 2025 14:14
@Jo-Byr Jo-Byr self-assigned this Aug 14, 2025
@jourdain
Copy link
Collaborator

Does that fix the issue you were running into?

@jourdain
Copy link
Collaborator

You need to add the blur event and do the update then?

@jourdain
Copy link
Collaborator

Or does the validate trigger the update call?

@Jo-Byr
Copy link
Contributor Author

Jo-Byr commented Sep 2, 2025

@jourdain

Does that fix the issue you were running into?

Yes it fixes the bug where it was not possible to have in the textfield a string that could not represent a valid number, even if it was a step towards a valid value. For example "1." preceding "1.2" was not possible to type, due to the update call reverting "1." to "1" to sanitize it.

Now such sanitizing is done through validate, on blur instead of on update.

You need to add the blur event and do the update then?

I don't understand what you mean.

Or does the validate trigger the update call?

validate does not call update explicitly but has similar code to call the type rule's conversion.

@jourdain
Copy link
Collaborator

jourdain commented Sep 2, 2025

Or does the validate trigger the update call?

validate does not call update explicitly but has similar code to call the type rule's conversion.

Are we now missing the update call? Is it needed or not?

@Jo-Byr
Copy link
Contributor Author

Jo-Byr commented Sep 3, 2025

Are we now missing the update call? Is it needed or not?

We don't need it as long as the blur event is triggerred.
I considered keeping the update as it was before (trigerred on every character change) while implementing a more complex logic to be able to tell what strings are "transitionnaly valid" (ex: 1., 1e-, 1.0000 but not 1a, x...). But the issue with this is that such corner cases require that we return a string rather than a float which is a breaking change.

This is why we settled on this simplification of validating inputs only at the end of the input, e.g. on blur.

The same validation process is at work in both update and validate with convert.value(value) calling the rule's convert method to sanitize the input.

@jourdain
Copy link
Collaborator

jourdain commented Sep 3, 2025

Should I merge?

Remove update on update:modelValue to fix bug preventing typing
non integer values in TextField
Remove condition on dirty call in validate to replace the call in
update
Uniformize TextField template.html structure
@Jo-Byr Jo-Byr force-pushed the fix-float-textfields branch from 24ddc75 to e7cc48b Compare September 4, 2025 12:58
@Jo-Byr
Copy link
Contributor Author

Jo-Byr commented Sep 4, 2025

@jourdain I made new modifications.

I removed the condition isDirty in validate because we need to make sure dirty() is called now that it is no longer called from update().

I also changed the update:focused to blur to be more uniform.

This also fixes a bug we had with some TextFields where we could only type one character at a time, with a forced blur being trigerred after each one.

@Jo-Byr
Copy link
Contributor Author

Jo-Byr commented Sep 8, 2025

@jourdain should we merge ?

@jourdain jourdain merged commit f005874 into Kitware:master Sep 8, 2025
6 checks passed
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.

2 participants