fix: use unmapped args for on-device controls#904
Open
adam-sajko wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue: native side of storybookjs/storybook#19130
Related (Core): storybookjs/storybook#35360
What I did
Fixed mapped
selectcontrols and conditionalifon device.useArgswas readingstory.args, which are the mapped values. Controls need the raw option keys (unmappedArgs), same as web. Because of that, a mappedselectcouldn't match its value back to an option, and anyifthat 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 toargs) for the initial state, on story change, and onSTORY_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
selectand an arg that depends on it:Set
icontostaron device:Before:
selectdoesn't reflectstar,iconPositiondoesn't show/apply.After:
staris selected,iconPositionshows and gets passed to the component.Does this need a new example in examples/expo-example? No, any story mixing
mappingwith anifreproduces it.Does this need an update to the documentation? No, no API change, just restores web parity.