prateekbh / preact-material-components

preact wrapper for "Material Components for the web"
https://material.preactjs.com
MIT License
553 stars 81 forks source link

Select should have a value prop #1286

Open photz opened 5 years ago

photz commented 5 years ago

In plain Preact you can choose which option of a select element should be selected like this:

<select value="2">
  <option value="1">Foo</option>
  <option value="2">Bar</option>
</select>

Unless I've missed something, then the Select component in this package only lets you set the selected option by either setting the selectedIndex prop of Select itself or using the selected prop of Select.Item.

I think it would make sense to let Select behave like a regular select in this regard, what do you think?

cromefire commented 5 years ago

If I'm correct, this is a current limitation by mdc or does this work with plain html?

prateekbh commented 5 years ago

Currently selectedIndex prop is an equivalent to value prop

cromefire commented 5 years ago

Well selectedIndex takes an index not a value

prateekbh commented 5 years ago

ah gotcha... sorry was attention was divided back then

Lets keep this for 2.0?