Open coreyworrell opened 9 months ago
@coreyworrell
I will be adding support for this next :)
I created my own based on your plugin. Perhaps it could be of help when implementing. Drag/drop sorting would be my next optimization but it's quite a bit more involved I think.
https://gist.github.com/coreyworrell/b653a82c3d92bd4461aa01646a606792
It looks really cool. I was thinking about using this: https://wordpress.github.io/gutenberg/?path=/story/components-formtokenfield--dropdown-selector
@creative-andrew I thought about that too, but I didn't see any way to sort the selections when using the FormTokenField component.
Edit: and I thought it would be too easy to accidentally remove a selected post with that.
Based on this: https://react-select.com/advanced#sortable-multiselect,
we can expand the FormTokenField
using https://www.npmjs.com/package/react-sortable-hoc
I saw that as well, and it could possibly work, but that library is no longer actively maintained (see note https://github.com/clauderic/react-sortable-hoc) and they recommended using @dnd-kit instead, which looks a bit more involved.
Either way though I felt that the multi-select token style was not as user friendly for managing the selected posts. Just my opinion of course.
I realize this goes against the plugin/repo name, but the WordPress plugin slug
query-loop-block-extensions
still fully encapsulates it. Anyways, it would be very cool to be able to select multiple posts and order them. The PHP side of things is basically already there, would just need to adjustposts_per_page
to match number of posts selected, and'orderby' => 'post__in'
.