-
-
Notifications
You must be signed in to change notification settings - Fork 8.9k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Form checker enhancements for radio #10081
Form checker enhancements for radio #10081
Conversation
@@ -536,21 +536,24 @@ function findNext(src, filter) { | |||
} | |||
|
|||
function findFormItem(src, name, directionF) { | |||
var name2 = "_." + name; // handles <textbox field="..." /> notation silently | |||
const name2 = "_." + name; // handles <textbox field="..." /> notation silently |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some minor tidyup in this function to use ===
and const
/ let
as well
//radio buttons have must be unique in repeatable blocks so name is prefixed | ||
r = e.name.indexOf("_", r + 8) + 1; | ||
if (e.tagName === "INPUT" && e.type === "radio" ) { | ||
if (e.checked === true) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved checked out of if so it doesn't fallthrough to the return on 552
} | ||
return name == e.name.substring(r); | ||
return false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if not checked continue and see if we can find a checked one
if (c.tagName === 'INPUT' && c.type === "radio") { | ||
document.querySelectorAll(`input[name='${c.name}'][type='radio']`) | ||
.forEach(element => { | ||
element.addEventListener("change", checker.bind(e)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bind to all of the radio buttons so that when someone clicks on one form validation is updated
/label ready-for-merge This PR is now ready for merge, after ~24 hours, we will merge it if there's no negative feedback. Thanks! |
Basically the same as #8832 except for general form validation and not
f:validateButton
Previously it only found the last radio button, it tried to find the checked one but then just fell through to the general code 😢. Updates didn't work either it just bound to the returned elements and not all of the radio buttons
Testing done
Tested in Azure VM agents as part of: jenkinsci/azure-vm-agents-plugin#604
Proposed changelog entries
Proposed upgrade guidelines
N/A
Submitter checklist
Desired reviewers
@mention
Before the changes are marked as
ready-for-merge
:Maintainer checklist