Commit 02d8ffda by Peter Holmberg

default value

parent 0f4131b8
...@@ -15,7 +15,9 @@ export default class UnitPicker extends PureComponent<Props> { ...@@ -15,7 +15,9 @@ export default class UnitPicker extends PureComponent<Props> {
const { defaultValue, onSelected } = this.props; const { defaultValue, onSelected } = this.props;
const unitGroups = kbn.getUnitFormats(); 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 => { const options = group.submenu.map(unit => {
return { return {
label: unit.text, label: unit.text,
...@@ -37,13 +39,12 @@ export default class UnitPicker extends PureComponent<Props> { ...@@ -37,13 +39,12 @@ export default class UnitPicker extends PureComponent<Props> {
}), }),
menuList: () => menuList: () =>
({ ({
WebkitOverflowScrolling: 'touch',
overflowY: 'auto', overflowY: 'auto',
position: 'relative', position: 'relative',
} as React.CSSProperties), } as React.CSSProperties),
}; };
const value = options.map(group => { const value = groupOptions.map(group => {
return group.options.find(option => option.value === defaultValue); return group.options.find(option => option.value === defaultValue);
}); });
...@@ -53,7 +54,7 @@ export default class UnitPicker extends PureComponent<Props> { ...@@ -53,7 +54,7 @@ export default class UnitPicker extends PureComponent<Props> {
className="width-20 gf-form-input--form-dropdown" className="width-20 gf-form-input--form-dropdown"
defaultValue={value} defaultValue={value}
isSearchable={true} isSearchable={true}
options={options} options={groupOptions}
placeholder="Choose" placeholder="Choose"
onChange={onSelected} onChange={onSelected}
components={{ components={{
......
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