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
feature: repeater and builder item drag and drop ordering #2017
Conversation
Thanks! Few points...
|
Maybe we should integrate our own Livewire integration of SortableJS. It's less than 100 LOC in this case and we don't need to rely on 3rd party packages. There is not much activity on that repo currently. UI wise I think I would prefer an area on the top-left/left side with a drag icon like this: Unfortunately there's no drag icon in heroicons. Maybe we could merge two "dots-vertical" to a drag icon 😅 |
Btw tests are failing because you bumped min PHP version on 2.x 😅 |
Yeah test error seems to be because of the composer requirements? Works fine with nested repeaters. Will change the drag handle as @pxlrbt suggested, and look at builder as well. |
Not sure how to improve this, but the drag handle feels a bit off 🙈 |
Mmmm yeah, I do feel it's a bit close to the field label. |
Wasn't the other implementation about 75 lines instead of 30? 🤔 |
Yeah, it included support for groups (for moving items between lists) which isn't needed so I didn't include it. Although that could potentially be an idea for a future feature, moving items between repeaters. |
Can me move stuff between nested repeaters - as Dan mentioned - without groups? |
Oh, no they're self-contained at the moment, you can't move something from one nested to repeater to a parent/child repeater at the moment... Do the regular up/down buttons support that? I think moving things between repeaters (whether nested or elsewhere on the page) would need some kind of user configuration to define which repeaters are grouped with one another, as field configurations could be different. |
Sure, you're right. Maybe that's out of scope for now. |
Yeah, certainly be nice to have, but maybe one for another day 🙂 . |
Now we're using a custom Livewire directive we shouldn't need the extra dispatch event methods anymore. I'll refactor that. |
maybe have the drag handle at the top center, heroicon-s-dots-horizontal, like ipad multitask dots? |
I also prefer the 4 |
I think 3 and 4 are my favourites, but we can get rid the old up / down buttons maybe? What do you think? |
I feel 4 is crowded but of course I’m biased towards 3 😆 |
+1 for 5 (aligned top left) |
I really like @panakour and @pxlrbt’s ideas of having a larger handle that could include the other actions as well. And possibly making this configurable as @wychoong suggested. But that probably needs more discussion, and I think it’d be good to get the core drag and drop functionality in place, so I’m gonna focus on that for this PR.
I’ve implemented 4 for now. That’s the simplest solution with the smallest UI impact. I’ve removed the up/down buttons but added arrow up/down key listeners to the drag handle, so it’s still keyboard accessible. Livewire seems to get glitchy if you add/remove these listeners on changes, so instead of toggling them in the view like the old buttons were I've added a check to the |
Co-authored-by: Dan Harrin <git@danharrin.com>
Co-authored-by: Dan Harrin <git@danharrin.com>
Co-authored-by: Dan Harrin <git@danharrin.com>
Co-authored-by: Dan Harrin <git@danharrin.com>
Yep. we can keep all clean |
Thank you very much! 🍻 |
Hey @jacksleight, after multiple bug reports it seems that this breaks sorting for nested repeaters. I've opened a PR which removes this feature here - #2156. I really don't want to merge it, but I've spent a while trying to find a solution and I cannot. It feels like Livewire is conflicting with the sortable package, which causes the moved items to appear above the parent repeater (DOM-diffing issue?). @ryangjchandler or @jacksleight if you're able to look into this today or tomorrow, that would be great. But if you don't have any time then that's absolutely fine, but I will need to merge #2156, probably tomorrow afternoon. |
To replicate the issue: Repeater::make('options')
->schema([
Repeater::make('values')
->schema([
TextInput::make('value'),
])
]), Add two items to the |
Thanks @ryangjchandler, fixed by #2164. |
@danharrin Hey, sorry I've been away so didn't catch this, wasn't ignoring it 😄 . Glad you found a fix! |
No worries mate, all sorted! Hope you had a good break |
Drag and drop ordering for repeater items:
Screen.Recording.2022-03-25.at.11.37.39.mov