Commit 8ab86c2c by Peter Holmberg

expand groups when searching

parent 2b8eab8c
......@@ -14,6 +14,14 @@ export default class UnitGroup extends PureComponent<ExtendedGroupProps, State>
expanded: false,
};
componentDidUpdate(nextProps) {
if (nextProps.selectProps.inputValue !== '') {
this.setState({ expanded: true });
} else {
this.setState({ expanded: false });
}
}
onToggleChildren = () => {
this.setState(prevState => ({
expanded: !prevState.expanded,
......
import React, { SFC } from 'react';
import { components } from 'react-select';
import { MenuProps } from 'react-select/lib/components/Menu';
interface ExtendedMenuProps extends MenuProps<any> {
data: any;
}
const UnitMenu: SFC<ExtendedMenuProps> = props => {
return (
<components.Menu {...props}>
<div>{props.children}</div>
</components.Menu>
);
};
export default UnitMenu;
......@@ -2,7 +2,6 @@ import React, { PureComponent } from 'react';
import Select from 'react-select';
import UnitGroup from './UnitGroup';
import UnitOption from './UnitOption';
import UnitMenu from './UnitMenu';
import ResetStyles from '../ResetStyles';
import kbn from '../../../utils/kbn';
......@@ -51,7 +50,6 @@ export default class UnitPicker extends PureComponent<Props> {
components={{
Group: UnitGroup,
Option: UnitOption,
Menu: UnitMenu,
}}
styles={styles}
/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment