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

A couple strange behaviors on input #456

Open
saveliy-sviridov opened this issue Sep 17, 2024 · 5 comments
Open

A couple strange behaviors on input #456

saveliy-sviridov opened this issue Sep 17, 2024 · 5 comments

Comments

@saveliy-sviridov
Copy link

saveliy-sviridov commented Sep 17, 2024

Hi, I have noticed a couple of issues when inputting values into the form that seem to not have been present before (although I don't know exactly when they appeared as I've only recently migrated to the vue3 version):

  • When modifying a value in an input, if you add or remove any characters from it, and then immediately go back to the original value ( "test" -> "test123" -> "test") before the debounce occurs, then, once it DOES occur, the final value that gets kept is actually the last value different from the original (in this example, it would be "test1"). This usually wouldn't be much of an issue if the debounce time is set to very low, however there is another, connected problem:
  • With the validateOn option being set to "blur", if you modify a value in a way that makes it not pass ajv validation, the moment validaton fails (on debounce, despite the validateOn value) the modification is discarded and the input returns to the original value. I have managed to avoid this problem by setting an extremely high debounce time, which makes validation of the form properly occur on blur instead of debounce, but that does mean it's much more common to trigger the first issue (and feels hacky). Setting updateOn: "input" and validateOn: "blur" seems to also resolve the issue, but in my use case I have to keep updateOn: "blur".

These are obviously not massive problems, but they seem somewhat obscure so I wanted to bring them to your attention.

@albanm
Copy link
Member

albanm commented Sep 17, 2024

Yes, thanks, I will have a look.

@albanm albanm self-assigned this Sep 17, 2024
@albanm
Copy link
Member

albanm commented Sep 23, 2024

This turned out to have somewhat complicated implications. There are quite large changes in the latest beta release, hopefully this should fix some bug as well as improve performance in some cases.

The first bug should be fixed.

About the second bug, for clarification : validateOn doest not control when the ajv validation is performed, but rather when the fields are considered as validated by the user (and so when errors should be displayed in the UI). Still there was a bug indeed. At least one case is fixed, I you still encounter an invalid behavior feel free to reopen the issue.

@albanm albanm closed this as completed Sep 23, 2024
@saveliy-sviridov
Copy link
Author

Thank you very much for a fast response (as usual!)

The first bug indeed seems to be completely resolved, but sadly I'm experiencing some very strange behavior in beta.46, although this is perhaps due to my implementation.

I'm using a property directly from my pinia store as vjsf's v-model with toRefs(store) (this is perhaps unadvisable?), which seems to have worked mroe or less properly before, however, in the latest version, when I manually edit any value in the form for the first time (after it gets initially hydrated with data from the store), the entire form is emptied except for the value I edited. The consequent edits, however, work just as expected.

Additionally, whenever I update the value in the store by any other mean, the form updates as well, and displays the correct data... however if I once again modify any value in the form manually, it goes back to the previous state, as if there were two forms - one that's correctly displaying the data from the store and the other that is completely independent from it.

Would you happen to have any idea what could be causing this? Could this indeed be related to my using a state value as v-model, or does that have nothing to do with it?

Also, please let me know if you would prefer that I create a separate issue for this.

@albanm
Copy link
Member

albanm commented Sep 24, 2024

No need to open a new issue.

Are you sure the vjsf version is the only change in the code base ? For now I fail to see what could cause what you observe. Using the editor shows that data-binding works in both directions (input from the form and applying external mutations). I don't know why using some state value from pinia would change that if it is exposed as a normal ref by toRefs.

If you don't find the bug yourself you can post some reproduction. I don't know what the best way to do it would be, maybe you could work in this directory in a fork.

@albanm albanm reopened this Sep 24, 2024
@saveliy-sviridov
Copy link
Author

Yeah, I've re-checked and it is indeed just the vjsf version; specifically the issue arises when going from beta-45 to beta-46.
I'll try a couple things on my side and post a reproduction as you advise if I can't resolve it, thanks.

@albanm albanm removed their assignment Oct 28, 2024
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

No branches or pull requests

2 participants