Description
The react implementation of <select>
does not appear to allow an <option disabled>
to be selected. This is correct behavior in the user timeline, but not at initial creation.
HTML allows for a <select>
to offer a selected <option disabled>
at creation time by wording its disallow to only update a select to a disabled option, and disallows the form to post if a disabled option is still selected. Whereas not explicitly allowing the pre-loaded <select>
to select an <option disable>
, all major browsers permit this.
HTML does not allow a <select>
to not have a selected option at any time. As such, it is idiomatic to have a disabled empty option (or one with placeholder text such as "pick a color") be the selected element at load time.
I believe that this example code should load to the first <option>
, but instead it loads to the second. If you remove disabled
from the unshifted element, then (and only then) is it selected at load time.
/** @jsx React.DOM */
var TestCase = React.createClass({
render: function() {
var options = [1,2,3,4,5,6,7,8,9,"Eisenhower"].map(function(X) {
return <option>{X.toString()}</option>;
});
options.unshift( <option value disabled selected> -- Select Eisenhower -- </option> );
return <select>{options}</select>;
}
});
Please advise.