-
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
Label undefined for Multiselect ArrayField #2378
Comments
Bump. If someone with knowledge of the internals could comment on my question, I would attempt to create a PR for this. |
What are `label` and `name` usually equal to for normal (non-multiselect)
array fields?
…--
Ashwin Ramaswami
On Mon, Jun 28, 2021 at 3:12 AM Maximilian Grundke ***@***.***> wrote:
Bump. If someone with knowledge of the internals could comment on my
question, I would attempt to create a PR for this.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#2378 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAM4MX3SSY4R7TSRMXIUOJ3TVAVGJANCNFSM44YBQ3XA>
.
|
My updated jsFiddle suggests To me it looks like an internal confusion of attributes at some point I cannot see right now, but to be honest, I'm not quite sure what exactly the |
It looks like @fsteger added that line (label={label}) in
#1301. I did note at
that time that "label" wasn't used at all. I'm guessing the way to fix this
is that "title" should actually be passed into the "label" prop. Does that
seem right to you?
…--
Ashwin Ramaswami
On Wed, Jun 30, 2021 at 2:35 AM Maximilian Grundke ***@***.***> wrote:
My updated jsFiddle <https://jsfiddle.net/rx6m8atn/> suggests label is
the key of the schema property. Other array variants use the name prop
<https://github.com/rjsf-team/react-jsonschema-form/blob/master/packages/core/src/components/fields/ArrayField.js#L463>,
while the multi select does not mention name and instead destructures the
undefined label attribute
<https://github.com/rjsf-team/react-jsonschema-form/blob/master/packages/core/src/components/fields/ArrayField.js?rgh-link-date=2021-05-12T07%3A56%3A20Z#L542>
.
To me it looks like an internal confusion of attributes at some point I
cannot see right now, but to be honest, I'm not quite sure what exactly the
label should be when we also have title for, well, the title of a field
and name for the field's name in the schema.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#2378 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAM4MX7MKGGNSCJB2D7ZUHDTVK3J3ANCNFSM44YBQ3XA>
.
|
I've created a PR that solves the problem for me. I don't know if this has any practical implications for anyother use case though. All tests pass locally. |
Prerequisites
JSFiddle: https://jsfiddle.net/f7xjq935/
Description
While implementing a highly customized rjsf in my current project, I use the
label
prop within the custom widgets to do some i18n / metadata lookup to render the widgets correctly (In essence, all forms are user-generated and the translated labels are provided by a third party). This works surprisingly fine.However, with an array field with unique items (aka Multiselect), the
label
prop of the custom widget isundefined
and no other prop can be used as a fallback (as far as I can see) to determine the name of the property in the schema.I have looked into the code and noticed, that in https://github.com/rjsf-team/react-jsonschema-form/blob/master/packages/core/src/components/fields/ArrayField.js#L542,
label
is in fact undefined (it's not part of the ArrayField props). However, there's thename
prop, which is not being used (and contains exactly what I need).Is this a bug or expected behavior? Would it be appropriate to set
label = this.props.name
?JSFiddle: https://jsfiddle.net/f7xjq935/
Steps to Reproduce
SelectWidget
with a custom component that renders thelabel
propVersion
2.5.1
The text was updated successfully, but these errors were encountered: