fix(plugin): correct argtype inference so URL param args apply to all controls - #56
Merged
davidpett merged 2 commits intoAug 5, 2026
Merged
Conversation
added 2 commits
August 3, 2026 16:07
… controls
Three bugs caused URL ?args= params to be silently dropped:
1. `inferSBType` used `in` to check array membership — always false, so every
scalar prop (string/number/boolean) got type `other` instead of the correct
scalar type. Fixed with `Array.includes()`.
2. `mapPropOptions` mapped plain-type props (e.g. `string`) to `[undefined]`
because Stencil emits `values: [{ type: "string" }]` without a `value` key.
`[undefined].length > 0` slipped past the original patch's guard.
Fixed by adding `&& value.value !== undefined` to the filter.
3. `inferSBType` returned `{ name: 'other' }` for union/enum types.
Storybook's `mapArgsToTypes` treats `other` as `INCOMPATIBLE` and drops
those args entirely. Fixed by returning `{ name: 'enum', value: [...] }`
when enumerated values are present — matching what Storybook's `map()`
expects for radio/select controls.
Wait for storybook-preview-iframe to exist and reach data-is-loaded=true before switching frame context, to avoid flaky frame-not-found errors in CI.
davidpett
approved these changes
Aug 5, 2026
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.
Summary
Fixes three bugs in
packages/plugin/src/docs/infer-type.tsandcustom-elements.tsthat caused Storybook URL?args=parameters to be silently dropped for Stencil components.Root causes
1.
inferSBType:inoperator used on an array (infer-type.ts)prop.type.toLowerCase() in scalarTypeschecks object keys, not array elements — alwaysfalse. Every scalar prop (string,number,boolean) got type{ name: 'other' }instead of the correct scalar type, preventing Storybook from coercing URL arg values.2.
mapPropOptions: plain-type props mapped to[undefined](infer-type.ts)Stencil emits
values: [{ type: "string" }](novaluekey) for non-union props. The old filter kept these entries and.map(({ value }) => value)produced[undefined]. Since[undefined].length > 0, the original patch'slength > 0guard didn't help — Storybook sawoptions: [undefined]and rejected any URL arg value.3.
inferSBType: union/enum types returned{ name: 'other' }(infer-type.ts)Storybook's internal
mapArgsToTypespasses each arg through amap()function that returnsINCOMPATIBLEfortype.name === 'other'(unlesstype.value === 'ReactNode'). This caused all radio/select union-typed props to be dropped when set via URL args. Fixed by returning{ name: 'enum', value: [...] }when enumerated values are present — matching the type Storybook expects for these controls.4.
tests/hmr.e2e.ts— fix flaky iframe switchingReplaced the inline
switchFramepredicate (which raced against Storybook's load cycle) with a dedicatedswitchToPreviewIframe()helper that waits for#storybook-preview-iframeto exist and fordata-is-loaded=truebefore switching frame context. Eliminates intermittent frame-not-found failures in CI.Changes
infer-type.ts—Array.includes()replacesinfor scalar type checkinfer-type.ts—mapPropOptionsfilters out entries with novaluekeyinfer-type.ts—inferSBTypereturnsSBEnumTypefor union types with enumerated valuescustom-elements.ts—options: undefinedinstead ofoptions: []for props with no enumerated values.gitignore— add.pnpm-store/tests/hmr.e2e.ts— replace racyswitchFramepredicate withswitchToPreviewIframe()helperTesting
Verified manually against the
examplepackage with all Stencil prop types (string,number,boolean, union/radio, union/select). URL args now apply correctly for all scalar and enum-typed props.