Skip to content

fix(controls): honor control: false and table.disable argTypes on device - #920

Merged
dannyhw merged 2 commits into
nextfrom
dannyhw/controls-honor-disable-argtypes
Sep 5, 2026
Merged

fix(controls): honor control: false and table.disable argTypes on device#920
dannyhw merged 2 commits into
nextfrom
dannyhw/controls-honor-disable-argtypes

Conversation

@dannyhw

@dannyhw dannyhw commented Sep 5, 2026

Copy link
Copy Markdown
Member

Issue: N/A. Only parameters.controls.exclude / include could hide a control on device; the per-argType forms Storybook documents for disabling controls for specific properties were ignored and the control still rendered as editable.

What I did

Storybook core handles include / exclude by deleting the argType in the inferControls enhancer, so those already worked. The three per-argType forms are left in place with a flag instead, and the panel's Boolean(argType.control) check passed them through because { disable: true } is truthy:

  • control: false (core normalizes this to control: { disable: true })
  • control: { disable: true }
  • table: { disable: true }

Changes:

  • Added controlArgTypes.ts in @storybook/addon-ondevice-controls with a getControlArgTypes helper that filters out disabled controls alongside the existing if conditional handling. The on-device panel has no description column, so all three forms hide the row rather than web's "row with a dash" for the control forms.
  • ControlsPanel now uses the helper and bases the "not configured to handle controls" warning on the filtered rows, so a story with every control hidden shows the warning instead of an empty table.
  • Added a ControlExamples/DisabledControls story in examples/expo-example covering each form plus exclude, with a test that composes the story and checks which rows survive.
  • Added a "Disabling Controls" section to the controls addon docs.
  • Changeset: patch for @storybook/addon-ondevice-controls.

How to test

pnpm build
pnpm --filter expo-example test components/ControlExamples/DisabledControls

Then in the example app open ControlExamples/DisabledControls:

  • Only Label Editable should show a single label control. The other four props are still rendered by the component but have no control.

  • All Disabled should show the "This story is not configured to handle controls" message.

  • ControlExamples/WebCompatibility/Undefined previously showed editable color controls despite control: false; they should now be hidden.

  • Does this need a new example in examples/expo-example? Yes, added DisabledControls.

  • Does this need an update to the documentation? Yes, added a section to docs/docs/intro/addons/controls.md.

The on-device Controls panel only hid an arg when it was removed by
parameters.controls.include/exclude, because core deletes those argTypes
before they reach the panel. The per-argType forms Storybook documents
for disabling a single control are left in place with a flag instead,
and the panel ignored the flag:

- control: false (normalized by core to control: { disable: true })
- control: { disable: true }
- table: { disable: true }

Since { disable: true } is truthy, the existing Boolean(argType.control)
check let these through and the control rendered as editable.

Move the row filtering into a controlArgTypes helper that checks the
disable flags alongside the existing if-condition handling, and base the
no-controls warning on the filtered rows so a story with every control
hidden shows the warning instead of an empty table.

Add a DisabledControls example story covering each form, a test against
the composed story, and a docs section.
@changeset-bot

changeset-bot Bot commented Sep 5, 2026

Copy link
Copy Markdown

馃 Changeset detected

Latest commit: d9f66a6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
@storybook/addon-ondevice-controls Patch
@storybook/addon-ondevice-actions Patch
@storybook/addon-ondevice-backgrounds Patch
@storybook/addon-ondevice-notes Patch
@storybook/react-native-theming Patch
@storybook/react-native-ui-common Patch
@storybook/react-native-ui-lite Patch
@storybook/react-native-ui Patch
@storybook/react-native Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@dannyhw
dannyhw merged commit 526d613 into next Sep 5, 2026
1 check passed
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