diff --git a/packages/grafana-ui/src/components/Segment/Segment.story.tsx b/packages/grafana-ui/src/components/Segment/Segment.story.tsx index 9de2b52933d..be31b41171e 100644 --- a/packages/grafana-ui/src/components/Segment/Segment.story.tsx +++ b/packages/grafana-ui/src/components/Segment/Segment.story.tsx @@ -18,8 +18,9 @@ const toOption = (value: any) => ({ label: value, value: value }); SegmentStories.add('Array Options', () => { const options = ['Option1', 'Option2', 'OptionWithLooongLabel', 'Option4'].map(toOption); + options[0].label = 'Option1 Label'; return ( - + {(value, updateValue) => ( <>
@@ -29,9 +30,9 @@ SegmentStories.add('Array Options', () => { ) => { - updateValue(value); - action('Segment value changed')(value); + onChange={item => { + updateValue(item); + action('Segment value changed')(item.value); }} /> { return ( - + {(value, updateValue) => ( <>
@@ -63,9 +64,9 @@ SegmentStories.add('Grouped Array Options', () => { ) => { - updateValue(value); - action('Segment value changed')(value); + onChange={item => { + updateValue(item); + action('Segment value changed')(item.value); }} /> { SegmentStories.add('With custom options allowed', () => { const options = ['Option1', 'Option2', 'OptionWithLooongLabel', 'Option4'].map(toOption); return ( - + {(value, updateValue) => ( <>
@@ -94,9 +95,9 @@ SegmentStories.add('With custom options allowed', () => { allowCustomValue value={value} options={options} - onChange={(value: SelectableValue) => { - updateValue(value); - action('Segment value changed')(value); + onChange={item => { + updateValue(item); + action('Segment value changed')(item.value); }} /> { ); }); -const CustomLabelComponent = ({ value }: any) =>
custom({value})
; +const CustomLabelComponent = ({ value: { value } }: any) =>
custom({value})
; SegmentStories.add('Custom Label Field', () => { return ( - + {(value, setValue) => ( <>
@@ -126,9 +127,9 @@ SegmentStories.add('Custom Label Field', () => { } options={groupedOptions} - onChange={(value: SelectableValue) => { - setValue(value); - action('Segment value changed')(value); + onChange={item => { + setValue(item); + action('Segment value changed')(item.value); }} /> ({ const [Label, width, expanded, setExpanded] = useExpandableLabel(false); if (!expanded) { - return