You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using a multi-select control such as multi-select, check, etc, will cause the mapped argument to only return an array containing the labels of the arguments.
// Button.stories.ts|tsx// Replace your-framework with the name of your frameworkimporttype{Meta}from'@storybook/your-framework';import{Button}from'./Button';import{ArrowUp,ArrowDown,ArrowLeft,ArrowRight}from'./icons';constarrows={ ArrowUp, ArrowDown, ArrowLeft, ArrowRight };constmeta: Meta<typeofButton>={/* 👇 The title prop is optional. * See https://storybook.js.org/docs/react/configure/overview#configure-story-loading * to learn how to generate automatic titles */title: 'Button',component: Button,argTypes: {arrow: {options: Object.keys(arrows),// An array of serializable valuesmapping: arrows,// Maps serializable option values to complex arg valuescontrol: {type: 'select',// Type 'select' is automatically inferred when 'options' is definedlabels: {// 'labels' maps option values to string labelsArrowUp: 'Up',ArrowDown: 'Down',ArrowLeft: 'Left',ArrowRight: 'Right',},},},},};exportdefaultmeta;
In the given example with the control's type set to select, selecting an item returns that item. For example, selecting "Up" will return ArrowUp.
However, if we replace that control's type to multi-select, selecting an additional item will return an array of labels instead, not an array of the selected items. For example, selecting "Up" and "Down" will return ["Up", "Down"] instead. (Or it should. I only tested with implicit labels. It may return ["ArrowUp", "ArrowDown"] instead.)
Current behavior:
When selecting one item it will return the object containing that item. When selecting multiple it returns an array of the options' labels.
Expected behavior:
When selecting one item it should return the object containing that item. When selecting multiple it should return an array or object containing all selected values.
Alternatively, when using controls allowing selecting multiple it should always return an array containing the selected objects.
Describe the bug
Using a multi-select control such as
multi-select
,check
, etc, will cause the mapped argument to only return an array containing the labels of the arguments.For example, using the example on Dealing with complex values we have this story:
In the given example with the control's
type
set toselect
, selecting an item returns that item. For example, selecting "Up" will returnArrowUp
.However, if we replace that control's
type
tomulti-select
, selecting an additional item will return an array of labels instead, not an array of the selected items. For example, selecting "Up" and "Down" will return["Up", "Down"]
instead. (Or it should. I only tested with implicit labels. It may return["ArrowUp", "ArrowDown"]
instead.)Current behavior:
When selecting one item it will return the object containing that item. When selecting multiple it returns an array of the options' labels.
Expected behavior:
When selecting one item it should return the object containing that item. When selecting multiple it should return an array or object containing all selected values.
Alternatively, when using controls allowing selecting multiple it should always return an array containing the selected objects.
To Reproduce
See reproduction stackblitz here: https://stackblitz.com/edit/github-yw4xwr?file=src/stories/List.stories.ts
System
Additional context
Reproduction should show as following.
No items
One item
Two items
Updated System info to result from reproduction repo.
The text was updated successfully, but these errors were encountered: