Skip to content

Commit

Permalink
Fix error stemming from selected prop on EuiSelect
Browse files Browse the repository at this point in the history
Apparently React doesn’t use this property and uses `value`/`defaultValue` similar to other inputs.
  • Loading branch information
cchaos committed Feb 23, 2018
1 parent 06bd42c commit 790fc54
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src-docs/src/views/form/form_rows.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export default class extends Component {
label="Select (with no initial selection)"
>
<EuiSelect
hasNoInitialSelection={true}
hasNoInitialSelection
options={[
{ value: 'option_one', text: 'Option one' },
{ value: 'option_two', text: 'Option two' },
Expand Down
10 changes: 6 additions & 4 deletions src/components/form/select/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const EuiSelect = ({
fullWidth,
isLoading,
hasNoInitialSelection,
defaultValue,
...rest
}) => {
const classes = classNames(
Expand All @@ -31,10 +32,10 @@ export const EuiSelect = ({
className
);

let emtpyOptionNode;
let emptyOptionNode;
if (hasNoInitialSelection) {
emtpyOptionNode = (
<option selected disabled hidden style={{ display: 'none' }}>&nbsp;</option>
emptyOptionNode = (
<option value="" disabled hidden style={{ display: 'none' }}>&nbsp;</option>
);
}

Expand All @@ -51,9 +52,10 @@ export const EuiSelect = ({
name={name}
className={classes}
ref={inputRef}
defaultValue={defaultValue || ''}
{...rest}
>
{emtpyOptionNode}
{emptyOptionNode}
{options.map((option, index) => {
const {
text,
Expand Down

0 comments on commit 790fc54

Please sign in to comment.