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

Commencement selected options fix #1401

Merged
merged 6 commits into from
Feb 11, 2022

Conversation

musangowope
Copy link
Contributor

@musangowope musangowope commented Feb 10, 2022

form.elements.provisions is a RadioNodeList
form.elements.provisions.selectedOptions is undefined

Fix:
if all_provisions is checked uncheck all provisions

resolves #1399

Copy link
Contributor

@longhotsummer longhotsummer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch -- minor tweak required.

@@ -84,7 +84,9 @@
// if we've selected all provisions, ensure we don't send back any selections
if (form.elements.all_provisions.checked) {
// we can't iterate over this in-place, so do this instead
while (form.elements.provisions.selectedOptions.length > 0) form.elements.provisions.selectedOptions[0].selected = false;
while ([...form.elements.provisions].some(provision => provision.checked)) {
form.elements.provisions[0].checked = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost... the goal of the original code is to uncheck everything when all_provisions is checked (it does the first element in selectedOptions only because selectedOptions slowly gets smaller and smaller.

The new code can just loop over all the elements and set checked to false on all of them.

longhotsummer
longhotsummer previously approved these changes Feb 11, 2022
@musangowope musangowope merged commit 236c60d into master Feb 11, 2022
@musangowope musangowope deleted the commencement-selected-options-fix branch February 11, 2022 11:20
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.

TypeError: Cannot read properties of undefined (reading 'selectedOptions')
2 participants