close drop down no matter how create theme menu is selected

main
Mike Fix 6 years ago
parent 7f7e38dbc8
commit f645791377

@ -57,13 +57,14 @@ class Dropdown extends React.PureComponent {
userInputtedValue = '' userInputtedValue = ''
render() { render() {
const { color, selected, onChange, itemWrapper, icon, disableInput } = this.props const { innerRef, color, selected, onChange, itemWrapper, icon, disableInput } = this.props
const { itemsToShow, inputValue } = this.state const { itemsToShow, inputValue } = this.state
const minWidth = calcMinWidth(itemsToShow) const minWidth = calcMinWidth(itemsToShow)
return ( return (
<Downshift <Downshift
ref={innerRef}
inputValue={inputValue} inputValue={inputValue}
selectedItem={selected} selectedItem={selected}
defaultHighlightedIndex={itemsToShow.findIndex(it => it === selected)} defaultHighlightedIndex={itemsToShow.findIndex(it => it === selected)}

@ -51,6 +51,8 @@ class Themes extends React.PureComponent {
selected: null selected: null
} }
dropdown = React.createRef()
componentDidMount() { componentDidMount() {
const storedThemes = getThemes(localStorage) || [] const storedThemes = getThemes(localStorage) || []
@ -76,9 +78,10 @@ class Themes extends React.PureComponent {
highlights: themes.find(({ id }) => id === preset).highlights highlights: themes.find(({ id }) => id === preset).highlights
})) }))
handleDropdown = ({ id }) => { handleChange = ({ id }) => {
if (id === 'create') { if (id === 'create') {
this.props.toggleVisibility() this.props.toggleVisibility()
this.dropdown.current.closeMenu()
} else { } else {
this.props.updateTheme(id) this.props.updateTheme(id)
} }
@ -153,13 +156,14 @@ class Themes extends React.PureComponent {
return ( return (
<div className="themes"> <div className="themes">
<Dropdown <Dropdown
innerRef={this.dropdown}
icon={themeIcon} icon={themeIcon}
disableInput={isVisible} disableInput={isVisible}
inputValue={dropdownValue} inputValue={dropdownValue}
selected={dropdownValue} selected={dropdownValue}
list={dropdownList} list={dropdownList}
itemWrapper={this.itemWrapper} itemWrapper={this.itemWrapper}
onChange={this.handleDropdown} onChange={this.handleChange}
onOpen={isVisible && toggleVisibility} onOpen={isVisible && toggleVisibility}
/> />
{isVisible && ( {isVisible && (

Loading…
Cancel
Save