Skip to content

Commit

Permalink
Added tests and another minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
yuri-sakharov committed Dec 17, 2017
1 parent d933d19 commit 14e7b18
Show file tree
Hide file tree
Showing 2 changed files with 165 additions and 125 deletions.
8 changes: 4 additions & 4 deletions src/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ const stringOrNumber = PropTypes.oneOfType([

let instanceId = 1;

const shouldShowValue = (state, props, isOpen) => {
const shouldShowValue = (state, props) => {
const { inputValue, isPseudoFocused, isFocused } = state;
const { onSelectResetsInput } = props;

if (!inputValue) return true;

if (!onSelectResetsInput && !isOpen){
if (!onSelectResetsInput){
return !(!isFocused && isPseudoFocused || isFocused && !isPseudoFocused);
}

Expand Down Expand Up @@ -812,7 +812,7 @@ class Select extends React.Component {
</ValueComponent>
);
});
} else if (shouldShowValue(this.state, this.props, isOpen)) {
} else if (shouldShowValue(this.state, this.props)) {
if (isOpen) onClick = null;
return (
<ValueComponent
Expand Down Expand Up @@ -840,7 +840,7 @@ class Select extends React.Component {
&& !this.state.inputValue
});
let value;
if (!this.props.onSelectResetsInput && !isOpen && !this.state.isFocused){
if (!this.props.onSelectResetsInput && !this.state.isFocused){
value= '';
} else {
value = this.state.inputValue;
Expand Down
Loading

0 comments on commit 14e7b18

Please sign in to comment.