Skip to content

Controls: Allow story argTypes to override control: false from meta#33729

Merged
valentinpalkovic merged 1 commit intostorybookjs:nextfrom
jonathan-fulton:fix/control-false-override-27091
Feb 3, 2026
Merged

Controls: Allow story argTypes to override control: false from meta#33729
valentinpalkovic merged 1 commit intostorybookjs:nextfrom
jonathan-fulton:fix/control-false-override-27091

Conversation

@jonathan-fulton
Copy link
Copy Markdown
Contributor

@jonathan-fulton jonathan-fulton commented Jan 31, 2026

Description

Fixes #27091

When meta defines argTypes: { prop: { control: false } }, story-level argTypes with control: 'text' or control: { type: 'select' } should be able to re-enable the control.

Problem

The issue was that:

  1. control: false was normalized to { disable: true }
  2. control: 'text' was normalized to { type: 'text' }
  3. When merged via combineParameters, both properties were kept, resulting in { disable: true, type: 'text' }
  4. The disable: true property meant the control stayed disabled

Solution

When a control type is explicitly specified in normalizeControl(), the normalized control object now includes disable: false to override any inherited disable: true from parent argTypes.

Changes

  • Modified normalizeControl() in normalizeInputTypes.ts to set disable: false when a type is specified
  • Added comprehensive tests for the new behavior

Backward Compatibility

  • control: false still disables controls ✅
  • control: { disable: true } still works ✅
  • control: { type: 'text', disable: true } still keeps control disabled ✅
  • But now control: 'text' properly overrides control: false

Example

// meta.ts
export default {
  argTypes: {
    prop: { control: false }  // Disabled at meta level
  }
};

// Story.stories.ts - BEFORE: control stayed disabled, NOW: control works
export const WithControl = {
  argTypes: {
    prop: { control: 'text' }  // Now properly overrides to enable control
  }
};

Summary by CodeRabbit

  • Bug Fixes
    • Fixed control normalization behavior to ensure that controls provided as strings or objects without an explicit disable flag now correctly default to being enabled with disable: false applied. This change properly overrides any inherited disabled state and ensures consistent and predictable behavior across all control specification formats used in the framework.

✏️ Tip: You can customize this high-level summary in your review settings.

Fixes storybookjs#27091

When meta defines `argTypes: { prop: { control: false } }`, story-level
argTypes with `control: 'text'` or `control: { type: 'select' }` should
be able to re-enable the control.

The issue was that `control: false` was normalized to `{ disable: true }`
and `control: 'text'` was normalized to `{ type: 'text' }`. When merged
via combineParameters, both properties were kept, resulting in
`{ disable: true, type: 'text' }` which still disabled the control.

The fix ensures that when a control type is explicitly specified, the
normalized control object includes `disable: false` to override any
inherited `disable: true` from parent argTypes.

This maintains backward compatibility:
- `control: false` still disables controls
- `control: { disable: true }` still works
- But now `control: 'text'` properly overrides `control: false`
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jan 31, 2026

📝 Walkthrough

Walkthrough

The normalizeInputTypes module is enhanced to set disable: false for controls provided as strings or objects lacking an explicit disable flag, overriding inherited disable: true. Comprehensive test coverage validates strict type preservation, disable flag inheritance, and control.type specification behavior.

Changes

Cohort / File(s) Summary
normalizeInputTypes Module
normalizeInputTypes.ts, normalizeInputTypes.test.ts
Enhanced normalizeControl to ensure disable: false is set for string controls and objects without explicit disable flags. Added test cases covering strict type preservation, disable flag inheritance scenarios, control.type specification, and explicit disable value retention.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@valentinpalkovic valentinpalkovic self-assigned this Feb 2, 2026
@valentinpalkovic valentinpalkovic moved this to Empathy Queue (prioritized) in Core Team Projects Feb 2, 2026
@valentinpalkovic valentinpalkovic changed the title Fix: Allow story argTypes to override control: false from meta Controls: Allow story argTypes to override control: false from meta Feb 2, 2026
@valentinpalkovic valentinpalkovic merged commit 931203f into storybookjs:next Feb 3, 2026
118 of 124 checks passed
@github-project-automation github-project-automation bot moved this from Empathy Queue (prioritized) to Done in Core Team Projects Feb 3, 2026
@github-actions github-actions bot mentioned this pull request Feb 3, 2026
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Bug]: Stories are not overwriting {control: false} from meta (argTypes)

2 participants