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

pat-sortable: Improve detection added/removed items #1197

Open
thet opened this issue Apr 3, 2024 · 0 comments
Open

pat-sortable: Improve detection added/removed items #1197

thet opened this issue Apr 3, 2024 · 0 comments

Comments

@thet
Copy link
Member

thet commented Apr 3, 2024

In pat-sortable we currently have some detection items which are added‌. This is done via the pat-update JavaScript event and via another event thrown by pat-inject. This covers all core-Patternslib use cases.

But this method for detecting new additions has some problems:

  • It's bound to Patternslib internals. It doesn't work if items are added from outside. We currently have a use-case in Mockup, where a svelte application is adding items to a container and these items should be sortable. We could also throw one of the events mentioned above, but this again make use of Patternslib internals and is not a generic solution which would work in any case.
  • There is currently no re-initialization on item removal.

These problems can be fixed by making use of MutationObservers which would filter for added or removed items matching the selector. We could further filter for only direct descendants of the Pattern element itself as we are doing it with the current implementation of pat-sortable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant