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

Relation widget crashes if valueField doesn't return string or component. #1116

Closed
tech4him1 opened this issue Feb 18, 2018 · 3 comments
Closed

Comments

@tech4him1
Copy link
Contributor

tech4him1 commented Feb 18, 2018

- Do you want to request a feature or report a bug?
bug

- What is the current behavior?
If the valueField for a relation widget isn't a string (or other renderable object in React), the CMS will crash.
- If the current behavior is a bug, please provide the steps to reproduce.
Example:

    fields:
      - label: "Related Post Date"
        name: "post_date"
        widget: "relation"
        collection: "posts"
        searchFields: ["title", "date"]
        valueField: "date"

Try to type into the relation widget.
- What is the expected behavior?
The relation widget should still work with fields that don't return strings or React components.

- Please mention your CMS, node.js, and operating system version.

1.2.0-dev

- Please link or paste your config.yml below if applicable.

@tech4him1 tech4him1 changed the title Relation widget crashes if valueField doesn't return renderable (string). Relation widget crashes if valueField doesn't return string or component. Feb 18, 2018
@tech4him1
Copy link
Contributor Author

tech4him1 commented Feb 18, 2018

This could potentially be "fixed" by converting the values to strings before including them in the relation widget. It would probably need done at: https://github.com/netlify/netlify-cms/blob/952a6d509f4e681d4757bef51d4b2011c72f77ad/src/components/EditorWidgets/Relation/RelationControl.js#L90 and https://github.com/netlify/netlify-cms/blob/952a6d509f4e681d4757bef51d4b2011c72f77ad/src/components/EditorWidgets/Relation/RelationControl.js#L106
I don't see any problem with just converting the value to a string when suggesting options (first code), but I don't like doing that for the actual saved value (second code). The saved value in the entry should be the actual value that's in the related post. We'll need to see if the second only affects the suggestion, or the actual saved value.

@tech4him1
Copy link
Contributor Author

@barthc
Copy link
Contributor

barthc commented Feb 21, 2019

Issue fixed in #1936

@barthc barthc closed this as completed Feb 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants