preact-material-components icon indicating copy to clipboard operation
preact-material-components copied to clipboard

Select should have a value prop

Open photz opened this issue 7 years ago • 4 comments

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?

photz avatar Feb 23 '19 22:02 photz

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

cromefire avatar Feb 23 '19 22:02 cromefire

Currently selectedIndex prop is an equivalent to value prop

prateekbh avatar Feb 24 '19 05:02 prateekbh

Well selectedIndex takes an index not a value

cromefire avatar Feb 24 '19 09:02 cromefire

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

Lets keep this for 2.0?

prateekbh avatar Feb 24 '19 21:02 prateekbh