Track last valid input state and auto-reset on blur #927
Closed
snoozbuster
started this conversation in
General
Replies: 1 comment 1 reply
-
the reason for the As for your plugin reseting a value back to before it was invalid: https://formkit.link/edfa6f1951870b3f585346eefca6cd5d |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey there. I have a requirement as described in the title - I want to automatically reset an input to the last valid value when the field is blurred, if the field is currently invalid. I figured I could do this with a plugin, and this is what I cooked up:
This... almost works. But sometimes if the user types very quickly, an invalid value gets stored in the
lastValue
before the validation kicks in. indeed, from my logs, it seems like the blocking counter settles even while there are validation errors:The third line here is incorrect - there is a validation rule of
['matches', '/.+\n+.+/']
on this field (it is only valid if there are at least 2 lines). it does eventually notice on lines 4 right afterward that the field is invalid, but by that time it is too late - the invalid value has already made it into thelastValue
variable and now the resetting won't work.Is there a better way to achieve this? I tried also using
settled:errors
as in this example but that event never seemed to be fired for me.Beta Was this translation helpful? Give feedback.
All reactions