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

fix querySelector in Form focusOnError when id includes dots #4280

Conversation

jroebu14
Copy link
Contributor

@jroebu14 jroebu14 commented Aug 20, 2024

Reasons for making this change

Fixes #4279

Fixes Form component focusOnFirstError throwing an error with additionalProperties schema and dot idSchema e.g.

Failed to execute 'querySelector' on 'Element': 'input[id^=root.title' is not a valid selector.

Fixes by adding double quotes around id in query selector.

Checklist

  • I'm updating documentation
  • I'm adding or updating code
    • I've added and/or updated tests. I've run npx nx run-many --target=build --exclude=@rjsf/docs && npm run test:update to update snapshots, if needed.
    • I've updated docs if needed
    • I've updated the changelog with a description of the PR
  • I'm adding a new feature
    • I've updated the playground with an example use of the feature

@@ -837,7 +837,7 @@ export default class Form<
let field = this.formElement.current.elements[elementId];
if (!field) {
// if not an exact match, try finding an input starting with the element id (like radio buttons or checkboxes)
field = this.formElement.current.querySelector(`input[id^=${elementId}`);
field = this.formElement.current.querySelector(`input[id^="${elementId}"`);
Copy link
Member

Choose a reason for hiding this comment

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

This seems like a straightforward change. Are you willing to add a test to verify it was fixed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@heath-freenome apologies, I made this PR right before going on vacation. I see it's been merged but would you still like me to add a unit test?

Copy link
Member

Choose a reason for hiding this comment

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

@heath-freenome apologies, I made this PR right before going on vacation. I see it's been merged but would you still like me to add a unit test?

@jroebu14 If you could, that would be great! Hope you had a great vacation

@heath-freenome
Copy link
Member

@jroebu14 Can you also update the CHANGELOG.md to add a new 5.20.2 with a note for the fix

@heath-freenome heath-freenome merged commit 018621e into rjsf-team:main Sep 10, 2024
5 checks passed
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.

Form component's focusOnFirstError throws an error with additionalProperties schema and dot idSchema
2 participants