-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Custom widget for array always shows label #3820
Comments
What are you trying to do with the widget and the array field. Perhaps you can override one of the Array-based templates instead? |
The requirement is to have a grid/table based editor for certain array types. Since we are using a third party grid library, using the templates would likely not work too well since the grid wants to handle the rendering itself. The use of custom ui:widget here works perfectly for us, its just that the label for the field always renders which seems like a bug to me. If you agree that it should be hidden and can point at roughly where the code for this is, I could take a stab at a pr for this. |
It should be being hidden by the |
Per the reproduction at https://codesandbox.io/s/rough-bird-f7yf2k, you can see that using a |
@doronrosenberg I was pointing you in the direction of the code |
My bad! The issue is indeed that getDisplayLabel() is returning true in this case, will take a look to see why. btw, https://rjsf-team.github.io/react-jsonschema-form/docs/contributing#development-server says you need to restart the dev server when making changes, but vite is using HMR to update the code on the fly as I make changes. |
There are two questions I have on fixing this: First, in https://github.com/rjsf-team/react-jsonschema-form/blob/main/packages/utils/src/schema/getDisplayLabel.ts#L37 the default value for showing the label is read from The second way to fix it is this if statement(https://github.com/rjsf-team/react-jsonschema-form/blob/main/packages/utils/src/schema/getDisplayLabel.ts#L46), where if we have a customWidget we will always show the label. If a custom widget is present, the label should probably be hidden.
becomes:
To me it looks like there are two bugs here (ui:schema not being the final override, custom array widgets result in label being shown), but defer to what you would consider the correct fix. |
I would say, if |
Hey @doronrosenberg I am also working on making a tabular UI for array items. So, like if there are 5 entries in an array then it should get represented in a tabular way. But I am not able to find a correct approach because firstly, I thought of overriding ArrayFieldItemTemplate but then problem was that whole aggregate formData is not coming at once, its coming to template item wise. Any solutions ? |
Prerequisites
What theme are you using?
core
Version
5.x
Current Behavior
Using a custom widget set via ui:schema for an array field, the label is being rendered by rjsf even if the label is disabled in ui:schema. If I remove the custom widget, the label is properly hidden, so seems to be an issue with custom widgets for array types.
See See https://codesandbox.io/s/rough-bird-f7yf2k for a simple reproduction.
Note that
A list of strings
, the label for the field, is still showing.From reading the documentation, this should be the correct way to hide the labels, and it works for non-array overrides.
Expected Behavior
If I override the rendering of a type using my custom widget, I would expect to be in full control and be able to hide everything related to the field I am taking over. Its part of what makes rjsf so powerful with the ui:schema.
Steps To Reproduce
See https://codesandbox.io/s/rough-bird-f7yf2k.
Environment
No response
Anything else?
Thanks!
The text was updated successfully, but these errors were encountered: