Skip to content

Commit

Permalink
Fix error stemming from selected prop on EuiSelect (#436)
Browse files Browse the repository at this point in the history
  • Loading branch information
cchaos authored Feb 23, 2018
1 parent 06bd42c commit f96bba2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and logic ([#390](https://github.com/elastic/eui/pull/390))
**Bug fixes**

- Fixed `EuiContextMenu` bug when using the keyboard to navigate up, which was caused by unnecessarily re-rendering the items, thus losing references to them ([#431](https://github.com/elastic/eui/pull/431))
- Fix error stemming from `selected` prop on `EuiSelect` ([#436](https://github.com/elastic/eui/pull/436))

# [`0.0.22`](https://github.com/elastic/eui/tree/v0.0.22)

Expand Down
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 f96bba2

Please sign in to comment.