From 02d8ffda5b118b5d0711c4f54fb2cfebe0c81d82 Mon Sep 17 00:00:00 2001 From: Peter Holmberg Date: Fri, 16 Nov 2018 16:35:42 +0100 Subject: [PATCH] default value --- public/app/core/components/Picker/Unit/UnitPicker.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/public/app/core/components/Picker/Unit/UnitPicker.tsx b/public/app/core/components/Picker/Unit/UnitPicker.tsx index 171807feed0..bbbac7f76f4 100644 --- a/public/app/core/components/Picker/Unit/UnitPicker.tsx +++ b/public/app/core/components/Picker/Unit/UnitPicker.tsx @@ -15,7 +15,9 @@ export default class UnitPicker extends PureComponent { const { defaultValue, onSelected } = this.props; const unitGroups = kbn.getUnitFormats(); - const options = unitGroups.map(group => { + + // Need to transform the data structure to work well with Select + const groupOptions = unitGroups.map(group => { const options = group.submenu.map(unit => { return { label: unit.text, @@ -37,13 +39,12 @@ export default class UnitPicker extends PureComponent { }), menuList: () => ({ - WebkitOverflowScrolling: 'touch', overflowY: 'auto', position: 'relative', } as React.CSSProperties), }; - const value = options.map(group => { + const value = groupOptions.map(group => { return group.options.find(option => option.value === defaultValue); }); @@ -53,7 +54,7 @@ export default class UnitPicker extends PureComponent { className="width-20 gf-form-input--form-dropdown" defaultValue={value} isSearchable={true} - options={options} + options={groupOptions} placeholder="Choose" onChange={onSelected} components={{