From 8ab86c2cebc781ba3cb0b948d7a8e5995a2c396e Mon Sep 17 00:00:00 2001 From: Peter Holmberg Date: Fri, 16 Nov 2018 14:40:24 +0100 Subject: [PATCH] expand groups when searching --- .../core/components/Picker/Unit/UnitGroup.tsx | 8 ++++++++ .../core/components/Picker/Unit/UnitMenu.tsx | 17 ----------------- .../core/components/Picker/Unit/UnitPicker.tsx | 2 -- 3 files changed, 8 insertions(+), 19 deletions(-) delete mode 100644 public/app/core/components/Picker/Unit/UnitMenu.tsx diff --git a/public/app/core/components/Picker/Unit/UnitGroup.tsx b/public/app/core/components/Picker/Unit/UnitGroup.tsx index c76d9ae16a0..9df8a27cc1a 100644 --- a/public/app/core/components/Picker/Unit/UnitGroup.tsx +++ b/public/app/core/components/Picker/Unit/UnitGroup.tsx @@ -14,6 +14,14 @@ export default class UnitGroup extends PureComponent expanded: false, }; + componentDidUpdate(nextProps) { + if (nextProps.selectProps.inputValue !== '') { + this.setState({ expanded: true }); + } else { + this.setState({ expanded: false }); + } + } + onToggleChildren = () => { this.setState(prevState => ({ expanded: !prevState.expanded, diff --git a/public/app/core/components/Picker/Unit/UnitMenu.tsx b/public/app/core/components/Picker/Unit/UnitMenu.tsx deleted file mode 100644 index 472661277c8..00000000000 --- a/public/app/core/components/Picker/Unit/UnitMenu.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import React, { SFC } from 'react'; -import { components } from 'react-select'; -import { MenuProps } from 'react-select/lib/components/Menu'; - -interface ExtendedMenuProps extends MenuProps { - data: any; -} - -const UnitMenu: SFC = props => { - return ( - -
{props.children}
-
- ); -}; - -export default UnitMenu; diff --git a/public/app/core/components/Picker/Unit/UnitPicker.tsx b/public/app/core/components/Picker/Unit/UnitPicker.tsx index 8d9d6d8bb1c..8087ea7467c 100644 --- a/public/app/core/components/Picker/Unit/UnitPicker.tsx +++ b/public/app/core/components/Picker/Unit/UnitPicker.tsx @@ -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 { components={{ Group: UnitGroup, Option: UnitOption, - Menu: UnitMenu, }} styles={styles} />