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

Selection to have an on:change event #520

Closed
sazzad-sat opened this issue Nov 27, 2024 · 1 comment · Fixed by #522
Closed

Selection to have an on:change event #520

sazzad-sat opened this issue Nov 27, 2024 · 1 comment · Fixed by #522

Comments

@sazzad-sat
Copy link

Currently there are no way to bind to let:selected data because of svelte's slot props limitations. A reasonable option can be including an event such as on:change to use it outside of the scope of Selection component.

<script>
  import { Selection } from "svelte-ux";

  let selectedOptions = []
</script>

<Selection
  let:selected
  on:change={(e: any) => {
    selectedOptions = e
  }}
>
  ...
</Selection>

{selectedOptions.length} // accessible outside
@techniq
Copy link
Owner

techniq commented Dec 3, 2024

@sazzad-sat good feedback. Added in 0.76.0

Note: Selection is a lightweight state component wrapper around selectionStore and you can use the store directly if you need more imperative control.

Svelte UX will soon use @layerstack/* packages so you can also use import { selectionStore } from '@layerstack/svelte-stores' - https://www.layerstack.dev/docs/svelte-stores/selectionStore

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

Successfully merging a pull request may close this issue.

2 participants