question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Same "root" id for different fieldset or input

See original GitHub issue

Description

The default bootstrap/core theme renders multiple id with the default root. This seems to be caused by https://github.com/rjsf-team/react-jsonschema-form/blob/75f734d8ec7beb29e60ac27ceaf6deadd2a71734/packages/core/src/components/fields/ObjectField.js#L33

Unfortunately, using a ObjectFieldTemplate it is not easy to override the id using the idPrefix and property name because both are not passed to the ObjectFieldTemplate. So no easy workaround afais, instead needs a fix here. FWIW, btw I think it would be great if ObjectField would also pass its name to ObjectFieldTemplate.

Steps to Reproduce

  1. Go to this playground
  2. Open devtools inspector
  3. Search for #root

Expected behavior

There should only be one unique id (also useful for anchors)

Actual behavior

There are six id=root in the rendered markup

Version

2.0.1

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:7
  • Comments:6

github_iconTop GitHub Comments

1reaction
jpsilva-daitancommented, May 4, 2021

@jpsilva-daitan I think I may have figured out the issue on my end, having to do with a missing value in the schema. I was missing type: "object", can you try

...
spec: {
  ...
  schema: {
    type: 'object',
    ...
  }
}

You are right, that was the problem. Thanks =)

0reactions
ghostcommented, Jul 29, 2021

Found the same problem when array of objects, solutions was the same - to add “object” type to “items”:

{
  "type": "object",
  "properties": {
    "someValues": {
      "type": "array",
      "items": {
        "type": "object",               // this is it
        "properties": {
          "prop1": {
            "type": "integer"
          }
        }
      }
    }
  }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

<fieldset>: The Field Set element - HTML - MDN Web Docs
This attribute takes the value of the id attribute of a <form> element you want the <fieldset> to be part of, even if...
Read more >
Difference between id and name attributes in HTML
The name attribute is used when sending data in a form submission. Different controls respond differently. For example, you may have several ...
Read more >
Using the fieldset and legend elements
It is possible to nest one <fieldset> element inside another, but it is not recommended. Screen readers do not automatically indicate the end...
Read more >
Apollo Federation subgraph specification
Grammatically, a FieldSet is a selection set minus the outermost curly braces. It can represent a single field ( "upc" ), multiple fields...
Read more >
FormControl API - Material UI - MUI
Learn about the props, CSS, and other APIs of this exported module. ... For instance, only one input can be focused at the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found