question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Reactive `selected` prop

See original GitHub issue

I’m surprised to read in the docs that the selected prop is static (“[…] or passed as prop to set pre-selected options that will already be populated when the component mounts before any user interaction”).

In my case, the selected options depend on the external context, the URL params, and when I go back/forward the MultiSelect has to update in consequence.

This worked as I expect with version 6.1.0 but since version 7.1.0, the selected prop has become static (it does not take new values into account).

Is this intended behavior?

As a workaround, I did use:

{#key selected}
  <MultiSelect {options} {selected} />
{/key}

Here is a quick-made REPL to demonstrate this: https://svelte.dev/repl/153f9049a9b849aa9fcc95117061a867?version=3.52.0

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
janoshcommented, Oct 22, 2022

Released in v8.0.0. I confirmed that installing

import MultiSelect from "svelte-multiselect@8.0.0"

in your REPL fixes the issue.

1reaction
janoshcommented, Oct 22, 2022

Yeah, I was just rereading your two-way binding recipe. Very cool that it works but it would require two new dependencies. I might just go with a wrapper component that dispatches events for testing whenever the two-way bound variable changes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

WebReflection/reactive-props: An all-in-one ... - GitHub
This module exports a default helper function that can create utilities to define reactive properties / states for data or DOM elements. For...
Read more >
Reactive properties - Lit.dev
Lit manages your reactive properties and their corresponding attributes. ... For example, a menu component might have a public selected property that can...
Read more >
SelectedFilters - Reactive Manual - Appbaseio Open Source
Most ReactiveSearch filter components have a prop showFilter (defaults to true ) which can be used to control whether the component's selected state...
Read more >
Reactive default prop value - Stack Overflow
It's not a good idea to provide a default value base on a variable directly in props, the default in props is considered...
Read more >
Props/Default Props - SolidJS · Reactive Javascript Library
Props objects are readonly and have reactive properties which are wrapped in Object getters. This allows them to have a consistent form regardless...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found