mirror of
https://github.com/grafana/grafana.git
synced 2025-08-02 02:42:09 +08:00
Select: Allow custom value for selects (#19775)
* WIP: simple poc of allow custom value for selects * Add support for custom value in segment * Update snapshots
This commit is contained in:
@ -36,3 +36,30 @@ SelectStories.add('default', () => {
|
||||
</UseState>
|
||||
);
|
||||
});
|
||||
|
||||
SelectStories.add('With allowCustomValue', () => {
|
||||
const intialState: SelectableValue<string> = { label: 'A label', value: 'A value' };
|
||||
const value = object<SelectableValue<string>>('Selected Value:', intialState);
|
||||
const options = object<Array<SelectableValue<string>>>('Options:', [
|
||||
intialState,
|
||||
{ label: 'Another label', value: 'Another value' },
|
||||
]);
|
||||
|
||||
return (
|
||||
<UseState initialState={value}>
|
||||
{(value, updateValue) => {
|
||||
return (
|
||||
<Select
|
||||
value={value}
|
||||
options={options}
|
||||
allowCustomValue={true}
|
||||
onChange={value => {
|
||||
action('onChanged fired')(value);
|
||||
updateValue(value);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
</UseState>
|
||||
);
|
||||
});
|
||||
|
Reference in New Issue
Block a user