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

toggleForm validates rules of hidden items #286

Open
TheLegs opened this issue Apr 27, 2022 · 0 comments
Open

toggleForm validates rules of hidden items #286

TheLegs opened this issue Apr 27, 2022 · 0 comments

Comments

@TheLegs
Copy link

TheLegs commented Apr 27, 2022

Version: 3.1.6

Bug Description

When there are toggle rules nested into elements which are in turn subjects of possible toggling, a specific situation may occur where, if a value was set while the item was displayed, but then the item is hidden, toggleForm() will continue to evaluate those rules against the hidden items. The consequence is that, for example, certain items keep being displayed when they should not be, or the user might not be able to submit a form due to a validation issue on an item that is hidden.

Steps To Reproduce

Set for example the following radio buttons:

  • item1 with a rule to toggle item2 on a certain value
  • item2 with a rule to toggle item3
  • item4 with a rule to toggle item3, and
  • item5 that has no toggle rules set

Then select item1 in order to toggle item2, then item2 in order to toggle item3.
Lastly, select item5.

Expected Behavior

When selecting item5, you should no longer see item3.

Possible Solution

toggleForm() should only call toggleControl() on controls that currently displayed.
Plus, I think the controls should be also reset when toggled out, to prevent data from being submitted unbeknownst to the user.

for (i = 0; i < form.elements.length; i++) {
if (form.elements[i].tagName.toLowerCase() in {input: 1, select: 1, textarea: 1, button: 1}) {
Nette.toggleControl(form.elements[i], null, null, !event);
}
}

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

1 participant