-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
feat(netlify-cms-widget-relation): use react-select and add support for multiple entries #1936
feat(netlify-cms-widget-relation): use react-select and add support for multiple entries #1936
Conversation
Preview proposed changes to netlifycms.org in the link below: Built with commit 23fdc64 |
Preview proposed changes to the CMS demo site in the link below: Built with commit 23fdc64 |
Horray! 🎉 was going to do something like this today, you just saved me a bunch of effort (: |
Going to hold onto this until we finish implementing tests for the widgets, working on it as we speak. |
I left some off-band review here: https://github.com/alexandernanberg/netlify-cms/pull/1 it's mostly compatibility with the code I implemented earlier in #1928 thumbs-up for testing it, especially with something like |
That's exactly what we're using 👍 |
Just ran into a use case where I needed to use multiple select in the relationship component. So happy to see this PR open. Awesome work @alexandernanberg. Looking forward to seeing this merged. |
Is there an estimate of when this might be merged in? |
@alexandernanberg apologies for the delay - this is a 1000% improvement, merging. Please keep 'em coming! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, did find one bug - an existing value doesn't show when you load an entry, only after focusing the relation field: https://deploy-preview-1936--cms-demo.netlify.com/#/collections/kitchenSink/entries/a-big-entry-with-all-the-things
No worries! Huh weird - I'll have a look asap (probably in a day or two) |
@alexandernanberg any reason why you omitted the relation widget's |
@barthc I don't see any mention of |
I guess the relation widget should be updated to work like the select widget (with the changes in #2054)? Though I'm not sure that I'm 100% onboard with the changes in that PR in retrospect, kind of makes sense to keep the same type always to me. Uncertain if it will break some Gatsby configs because you expect to receive an empty array instead of null 🤔 |
Also the bug seems to have gone away... not sure why ¯_(ツ)_/¯ |
Good point on It looks like the preview isn't working here, but it is working on master. There was always an issue where the preview sometimes didn't show initially, but you can test by typing "json" into the field and selecting the "This is a JSON front matter post" entry. You'll notice on master it loads the preview, but in this PR updating the value still doesn't show the preview. |
Ah, it's the thing @barthc was talking about, figured I was missing something when he said that 🙄 The original The new Note: in case you don't have it, the Redux dev tools extension is super helpful for troubleshooting. |
I think the metadata should work like before now. But I found some other bugs that I've been unable to solve... if you search for eg. "YAML" and select that post, then try to select another one without searching the selectedValue will be null. That's because Not sure how we'd handle this 🤔 |
Gotcha - the previews are definitely fixed, thanks for that 👍👍 @barthc would you be up for reviewing this and weighing in on the |
A couple of things. The kitchen sink
I suggest you store the initial |
@alexandernanberg if you don't mind, I would like to push a commit, that would address my comments. |
@barthc That would be great since I don't have time right now. You should have push access to my fork now! It would be nice it we could solve the intial preview without updating the state imo, but that might not be possible? 🤔 |
@alexandernanberg @erquhart review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking since we have all the "options/hits" already loaded in allOptions
, does it still make sense to query them?
LGTM otherwise 👍
onChange(fromJS(value), { | ||
[field.get('name')]: { | ||
[field.get('collection')]: { | ||
[last(value)]: !isEmpty(selectedOption) && last(selectedOption).data, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how the underlying mechanics works here but wouldn't it be better to have this as a list somehow – instead of just picking the last item
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The last item will always be the newly added item on the list, so we are guaranteed that all selected item will have their metadata in store. We cannot use list here because that would mean using List()
as key here [last(value)]
.
Yes we have all hits, but we still need to select the items that matches the query using the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for all of your work on this @alexandernanberg! Thanks for reviewing and wrapping it up @barthc, and extra thanks for the tests, they help a lot!!
Does this mean this should now be available for everyone use? Is there an example of code for the config.yml? |
@sanscheese you would need to add the multiple options to the widget |
@barthc Hmm. I tried that. It looks like the field is still using This is the field I've setup in my config.yml
My I can see the new multi-relation using the kitchenSink in the |
@erquhart is the new |
No, releasing today. Was working on some way to provide |
This is amazing timing for me! Congrats, and great work on this! 😀 |
Update: this was released in 2.5.0 🎉 |
I must say: It looks and works very well! Great work! |
Summary
Closes #1061
Related to #1928 but this only focuses on the existing
relation
widget. The behavior should be the same as the old one. Before I continue on this I'd like some confirmation if this can "live" beside the other PR, did this pretty quickly to play around a bit.Test plan
So far just manual testing – should probably add some unit tests