Is sp-picker now official?

​ I am now seeing this message in Dev Tool:
“sp-dropdown is deprecated. Please use sp-picker instead.”
However, when I tried to switch out my dropdown to sp-picker, it does not function properly. I also cannot find picker in the UXP docs.
If I keep using sp-dropdown, is my plugin going to stop working sometime soon?

Actually you can use <sp-picker />, but it’s a mix of both picker and dropdown

I use it like:

<sp-picker label="Label">
    <sp-label slot="label">Label</sp-label>
    <sp-menu slot="options">
        <sp-menu-item value="value1" selected=true>Value 1</sp-menu-item>
        <sp-menu-item value="value2">Value 2</sp-menu-item>
        <sp-menu-item value="value3">Value 3</sp-menu-item>
    </sp-menu>
</sp-picker>
1 Like

Perfect…that works! Thank you!

Related with this, I am trying to add sp-menu-item dinamically but then I can’t selected.

With first option, it doesnt work because selected is changed to null automatically and always it selects last index

<sp-menu slot="options">
                {items.map((item, index) => (
                  <sp-menu-item key={index} selected={selectedLanguage(index)}>
                    {item}
                  </sp-menu-item>
                ))}
              </sp-menu>

In second option with “value=‘0’”, it doesn’t work


<sp-menu slot="options" value="0">
                {items.map((item, index) => (
                  <sp-menu-item key={index}>
                    {item}
                  </sp-menu-item>
                ))}
              </sp-menu>

Also I have problems with onChange, because it doesn’t call the funcion

      <sp-dropdown onChange={changeHandler}>
        .....
      </sp-dropdown>

       <sp-picker label="Label" size="s" onChange={changeHandler}>
        .....
      </sp-picker>

Someone knows solutions?

Try

selected={selectedLanguage(index) ? true : null}

It can be only one of true or null. It can’t be false.

1 Like

YES!! It works, much thanks!