-
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
Allow item name/label to be passed to 'Add item' or 'Remove' buttons #4424
Comments
@kuhlaid What you suggest is a good feature to have. If you are willing to do the work, here are most of the steps you would need to take for the implementation:
That's alot, and if anyone would like to attempt this, feel free to ask any questions |
Thank you @heath-freenome, your steps were very helpful. I began testing this solution. I added the implementation to the RemoveButton within the core as an example. I did not change the
I wrapped the buttonName in single quotes because it seemed weird without them. The result renders as the following using the core theme and the playground Arrays JSONSchema (I am hovering over the Remove button on the I believe something like this will work. NOTE: While reviewing the solution I noticed that the |
Prerequisites
What theme are you using?
bootstrap-4
Is your feature request related to a problem? Please describe.
I have a schema that looks like:
Using the bootstrap-4 theme as an example (using the https://rjsf-team.github.io/react-jsonschema-form/ playground), after I add a file, a 'Remove' button appears next to the Keywords field. This is simply a coincidence due to the schema layout, but makes it appear that the remove button is associated with the Keywords field (which it is not). The remove button, when hovered over simply says 'Remove' without any qualifier as to 'What' it is removing (see screenshot below).
I read through https://rjsf-team.github.io/react-jsonschema-form/docs/advanced-customization/internals/#custom-array-field-buttons and it seems that these labels are controlled by CSS, but the javascript themes seem to mostly reference
<IconButton title={translateString(TranslatableString.RemoveButton)}
which uses the enumerated constant TranslatableString to define the 'title' of the button.Describe the solution you'd like
It would be helpful if the item label could be passed to the title of the 'Remove' button and 'Add' button. So in the case above where the Remove button is for the file, it would be nice if the Remove button title read something like 'Remove Files-0'. And instead of the Keywords 'Add' button having a title of 'Add item' it would read 'Add Keywords'.
I'm guessing the buttons could possibly read the 'label' from the widgets as mentioned in
react-jsonschema-form/CHANGELOG.md
Line 1101 in 5335d72
Describe alternatives you've considered
No response
The text was updated successfully, but these errors were encountered: