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

Wrong Select initialisation? #41

Closed
mwamp opened this issue Oct 15, 2019 · 5 comments
Closed

Wrong Select initialisation? #41

mwamp opened this issue Oct 15, 2019 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@mwamp
Copy link
Contributor

mwamp commented Oct 15, 2019

I have the following issue (which I have not tested on a minimal example)

value="orange"
<Select bind:value={value}>
 <Option value="" selected={value===""}></Opt>
<Option value="orange" selected={value==="orange}></Opt>
</Select>

In my case, the previous code would start with value=""

Proposed fix (Select.svelte)

onMount(async () => {
    select = new MDCSelect(element);
    select.value = value; //FIX is Here
    
    menuPromiseResolve(select.menu_);

    if (!ripple && select.ripple) {
      select.ripple.destroy();
    }

    if (updateInvalid) {
      invalid = inputElement.matches(':invalid');
    }
  });

works for me

@MintyMods
Copy link
Contributor

+1 Also works for me. I have previously been using the following to trigger the update for selects:-

  let selected;
  onMount(async()=>{
    await tick();
    selected = shape;
  })
...<Option value={option.type} selected={option.type === selected}>

Sticking that fix in allows me to remove 6 lines of code from each select component I use.

@mwamp
Copy link
Contributor Author

mwamp commented Oct 15, 2019

Thx for the feedback, let me propose the change
#42

@Eradash
Copy link
Contributor

Eradash commented Oct 24, 2019

@mwamp I tested the fix in my project and it works well!

@hperrin
Copy link
Owner

hperrin commented Oct 28, 2019

I don't think any of my demos actually start with a value. That should be fixed. xD

@hperrin hperrin self-assigned this Oct 28, 2019
@hperrin hperrin added the bug Something isn't working label Oct 28, 2019
@hperrin
Copy link
Owner

hperrin commented Oct 28, 2019

Fixed in 66af45d

@hperrin hperrin closed this as completed Oct 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants