Skip to content

Commit

Permalink
fix(select): allow initial value to change
Browse files Browse the repository at this point in the history
Also set zIndex of menu to fix issues with display on Style Guide
  • Loading branch information
aldeed committed Jul 17, 2018
1 parent 13f1159 commit 4eb7f08
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion package/src/components/Select/v1/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import PropTypes from "prop-types";
import ReactSelect from "react-select";
import { applyTheme, CustomPropTypes } from "../../../utils";

// This is currently mostly to ensure that this stays above our code examples in the
// style guide UI, which have zIndexes of 2 and 3 in some places. This might need to
// be taken from the theme eventually, though, if people have problems in other places.
const MENU_Z_INDEX = 4;

const nullDefaultEquals = (value1, value2) => ((value1 || null) === (value2 || null));

// Rather than pass through all props to react-select, we'll keep a whitelist
Expand Down Expand Up @@ -83,6 +88,12 @@ function getCustomStyles(props) {
borderColor: getInputBorderColor({ ...props, isFocused: state.isFocused }),
borderRadius: getInputBorderRadius(props)
};
},
menu(base) {
return {
...base,
zIndex: MENU_Z_INDEX
};
}
};
}
Expand Down Expand Up @@ -434,7 +445,8 @@ class Select extends Component {
}

render() {
const { isReadOnly, options, value } = this.props;
const { isReadOnly, options } = this.props;
const { value } = this.state;

// Unfortunately right now, react-select optgroup support is just a tad different from the
// composable form spec. Might be able to do a PR to get react-select updated.
Expand Down

0 comments on commit 4eb7f08

Please sign in to comment.