Skip to content

fix: use unmapped args for on-device controls#904

Open
adam-sajko wants to merge 1 commit into
storybookjs:nextfrom
adam-sajko:fix/ondevice-unmapped-args
Open

fix: use unmapped args for on-device controls#904
adam-sajko wants to merge 1 commit into
storybookjs:nextfrom
adam-sajko:fix/ondevice-unmapped-args

Conversation

@adam-sajko

@adam-sajko adam-sajko commented Jul 2, 2026

Copy link
Copy Markdown

Issue: native side of storybookjs/storybook#19130

Related (Core): storybookjs/storybook#35360

What I did

Fixed mapped select controls and conditional if on device.

useArgs was reading story.args, which are the mapped values. Controls need the raw option keys (unmappedArgs), same as web. Because of that, a mapped select couldn't match its value back to an option, and any if that points at a mapped arg was compared against the mapped value instead of the key, so it toggled wrong.

Now it reads unmappedArgs (falls back to args) for the initial state, on story change, and on STORY_ARGS_UPDATED. The event payload is mapped, so I re-read the story to get the unmapped values. Same behavior as web now.

How to test

Story with a mapped select and an arg that depends on it:

argTypes: {
  icon: {
    control: { type: 'select' },
    options: ['none', 'star'],
    mapping: { none: undefined, star: <StarIcon /> },
  },
  iconPosition: {
    if: { arg: 'icon', eq: 'star' },
    control: { type: 'radio' },
    options: ['left', 'right'],
  },
}

Set icon to star on device:

  • Before: select doesn't reflect star, iconPosition doesn't show/apply.

  • After: star is selected, iconPosition shows and gets passed to the component.

  • Does this need a new example in examples/expo-example? No, any story mixing mapping with an if reproduces it.

  • Does this need an update to the documentation? No, no API change, just restores web parity.

@adam-sajko adam-sajko requested a review from dannyhw as a code owner July 2, 2026 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant