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

Option list unwanted memory autosave form #1721

Open
polygonwood opened this issue Jul 28, 2022 · 4 comments
Open

Option list unwanted memory autosave form #1721

polygonwood opened this issue Jul 28, 2022 · 4 comments
Milestone

Comments

@polygonwood
Copy link

polygonwood commented Jul 28, 2022

Describe the bug

Using a (small) autoform , type normal with autosave=true and on-submit hook to perform action, consisting of only one input field with options, there is a 'memory' effect of last selected option.
E.g. select a value (which in my case restricts a query), move away from that route (iron router), come back to the route, it looks like re-freshed but when you click the same option you selected before, the submit hook is not executed. Selecting another value triggers the submit hook again

A clear and concise description of what the bug is.

To Reproduce

I have created a replicator : live on galaxy
source code on github

click on route 1, select e.g. option 1 from drop down selector,
go back to top and click again on route 1 and select the same option, you will see no response below (or in console), selecting another option does trigger the on-submit hook again

Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior

I expect Autoform.resetForm(formID) to clear the memory of the last selected option. Any selected option after reset should re-trigger the submit hook.

Screenshots

If applicable, add screenshots to help explain your problem. Please avoid
screenshots of code or error outputs and use formatted code via markdown
instead.

movie at link recording shows the behavior, at around second 10-11 you see the unwanted behaviour (not reacting to selection option 'Bestuur' for the second time ...)

Versions (please complete the following information):

  • Meteor version: [e.g. 1.8.2]
  • Browser: [e.g. firefox, chrome, safari]
  • Package version: [e.g. 1.0.0]

Meteor 2.7.3
Autoform 7.0.0
Browser Chrome 103

Additional context

Add any other context about the problem here.

@jankapunkt
Copy link
Member

Thank you @polygonwood I will take a look at it. I already found resetForm not to be working properly.

@polygonwood
Copy link
Author

polygonwood commented Jul 29, 2022 via email

@polygonwood
Copy link
Author

Jan
This has to do with the module variable lastKeyVals in autoform-events.js Once an autosave event has occurred, the last value of the last changed field is kept in the lastKeyVals object, even after submit, reserForm, ...
I have solved it for my application by adding a clearLastKeyVal() function to the hookContext, allowing me to clear that memory e.g. in a onSubmit hook (so that next usage of the form doesn't suffer from that). This could perhaps also be added to the resetForm in general ?
I'm not generating a pull request because I'm not to deeply knowledgable to understand what the preferred option is to avoid this situation.

@jankapunkt
Copy link
Member

possible to be fixed via #1602

@jankapunkt jankapunkt added this to the v7 milestone Oct 31, 2023
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