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

Give ids to array and object fields #1102

Merged
merged 4 commits into from Jan 10, 2019
Merged

Conversation

epicfaace
Copy link
Member

@epicfaace epicfaace commented Dec 8, 2018

This change:

  • Gives ids to the <fieldset> tag in the default array field template and object field template
  • Gives the id of "root" to the topmost <fieldset> in the form.

Reasons for making this change

This way, we are more consistent with the idSchema, so that every id mentioned in the idSchema actually has a corresponding element rendered in the DOM. This allows us to create anchor links that go to specific elements, even if they are not <input> or <select> elements.

For example, on the "Arrays" example in the playground, here is the idSchema:
image
However, there are no elements with ids equal to "root", "root_fixedItemsList", etc. This change fixes that.

This change was especially motivated by looking into #86 -- sometimes you may have a validation error that refers to an array element (such as minimum items not being reached). If there is no corresponding DOM ID corresponding to the idSchema value for that element, then we cannot create anchor links that go to the specific element with the error.

Checklist

  • I'm updating documentation
    • I've checked the rendering of the Markdown text I've added
    • If I'm adding a new section, I've updated the Table of Content
  • I'm adding or updating code
    • I've added and/or updated tests
    • I've updated docs if needed
    • I've run npm run cs-format on my branch to conform my code to prettier coding style
  • I'm adding a new feature
    • I've updated the playground with an example use of the feature

@epicfaace epicfaace changed the title Patch ids Give ids to array and object fields Dec 8, 2018
@glasserc
Copy link
Contributor

Thanks for the great PR description!

@glasserc glasserc merged commit 597a7ba into rjsf-team:master Jan 10, 2019
@glasserc
Copy link
Contributor

Also, sorry for taking so long to get to this!

@epicfaace epicfaace deleted the patch-ids branch August 24, 2019 04:47
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.

None yet

2 participants