Preact: Uncontrolled select support?

Created on 23 Jul 2020  路  4Comments  路  Source: preactjs/preact

Hi, the _defaultValue_ attribute for <select> does not work in preact: https://stackblitz.com/edit/preact-bug-defaultvalue-zn7r9a .

Switching to a selected attribute (in <option> ) seems to work but causes some strange behaviour on late renderings (no sandbox yet).

Most helpful comment

To be clear for anyone looking to work on this, defaultValue on <select> is not a DOM prop (MDN) but is something React supports, so support for defaultValue on <select> needs to be in preact/compat.

<option> does have a defaultSelected property (MDN), but not sure what React does with this.

All 4 comments

Does defaultValue even exist for <select>?

It might be some special handling react does

Hi @ForsakenHarmony , yes it exists; React even asked me (with a console warning) to replace <option default... /> by defaultValue during my tests ;-) .

Edit - Here is the React warning:
Warning: Use the "defaultValue" or "value" props on <select> instead of setting "selected" on <option>.

To be clear for anyone looking to work on this, defaultValue on <select> is not a DOM prop (MDN) but is something React supports, so support for defaultValue on <select> needs to be in preact/compat.

<option> does have a defaultSelected property (MDN), but not sure what React does with this.

Hello there, If this issue is up for taking I would like to help.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rajaraodv picture rajaraodv  路  3Comments

marcosguti picture marcosguti  路  3Comments

jasongerbes picture jasongerbes  路  3Comments

kay-is picture kay-is  路  3Comments

mizchi picture mizchi  路  3Comments