[PR #27187] fix(storybook): add required handler props and fix TypeScript errors in component stories #31708

Closed
opened 2026-02-21 20:49:59 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/27187

State: closed
Merged: Yes


Fix TypeScript type errors across multiple Storybook stories by adding required event handler properties to meta definitions. This ensures all stories properly type-check while maintaining interactive functionality.

Changes:

  • Add default onChange/onSelect/onConfirm/onCancel handlers to component meta args
  • Add argTypes for onChange to support Storybook actions panel
  • Set parameters: { controls: { disable: true } } for custom render stories
  • Add missing required props (items, value, isShow) to story args
  • Cast custom render stories to Story type using as unknown as Story

Components fixed:

  • AutoHeightTextarea: Add onChange to argTypes and default args
  • Confirm: Add onConfirm and onCancel handlers, add isShow to all story args
  • InputNumber: Add onChange handler and fix story type assertions
  • RadioCard: Fix story type assertions for custom render stories
  • SearchInput: Add onChange to argTypes, args, and individual stories
  • Select: Add onSelect handler and items prop to stories
  • Slider: Add onChange handler and fix story type assertions
  • TagInput: Add onChange to argTypes and default args
  • Textarea: Add value prop and fix story type assertions

Additional fixes:

  • chat/answer: Use WorkflowRunningStatus enum instead of string literal
  • voice-input: Fix Array.fill() call with explicit argument
  • storybook/main: Remove unused fileURLToPath and __dirname imports

Important

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue and you have been assigned to it
  3. Use the correct syntax to link this PR: Fixes #<issue number>.

Summary

fix #27185

Primary Fix: Add Required Event Handlers to Storybook Stories

1. AutoHeightTextarea (auto-height-textarea/index.stories.tsx)

  • Add onChange configuration to argTypes
  • Add default onChange handler to meta args

2. Confirm (confirm/index.stories.tsx)

  • Add onConfirm and onCancel handlers to meta args
  • Add missing isShow: false property to all stories

3. InputNumber (input-number/index.stories.tsx)

  • Add default onChange handler to meta args
  • Add parameters: { controls: { disable: true } } and type assertions to all custom render stories

4. RadioCard (radio-card/index.stories.tsx)

  • Add parameters: { controls: { disable: true } } and as unknown as Story type assertions to all custom render stories

5. SearchInput (search-input/index.stories.tsx)

  • Add onChange configuration to argTypes
  • Add default onChange handler to meta args
  • Add missing value and onChange properties to some stories
  • Add type assertions to all custom render stories

6. Select (select/index.stories.tsx)

  • Add default onSelect handler to meta args
  • Add missing items: [] property to all simple stories
  • Add parameters: { controls: { disable: true } } and type assertions to all custom render stories

7. Slider (slider/index.stories.tsx)

  • Add default onChange handler to meta args
  • Add parameters: { controls: { disable: true } } and type assertions to all custom render stories

8. TagInput (tag-input/index.stories.tsx)

  • Add onChange configuration to argTypes
  • Add default onChange handler to meta args
  • Add parameters: { controls: { disable: true } } and type assertions to all custom render stories

9. Textarea (textarea/index.stories.tsx)

  • Add missing value: '' property to multiple stories
  • Add parameters: { controls: { disable: true } } and type assertions to all custom render stories

10. Other Fixes

  • chat/answer/index.stories.tsx: Use WorkflowRunningStatus.Succeeded enum instead of string literal 'succeeded'
  • voice-input/index.stories.tsx: Fix Array.fill() call from .fill() to .fill(0)
  • .storybook/main.ts: Remove unused fileURLToPath and __dirname imports

Statistics

  • Files modified: 12 files
  • Lines added: +189
  • Lines deleted: -62
  • Net change: +127 lines

Screenshots

Before After
... ...
... CleanShot 2025-10-21 at 15 20 29

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods
**Original Pull Request:** https://github.com/langgenius/dify/pull/27187 **State:** closed **Merged:** Yes --- Fix TypeScript type errors across multiple Storybook stories by adding required event handler properties to meta definitions. This ensures all stories properly type-check while maintaining interactive functionality. Changes: - Add default onChange/onSelect/onConfirm/onCancel handlers to component meta args - Add argTypes for onChange to support Storybook actions panel - Set `parameters: { controls: { disable: true } }` for custom render stories - Add missing required props (items, value, isShow) to story args - Cast custom render stories to `Story` type using `as unknown as Story` Components fixed: - AutoHeightTextarea: Add onChange to argTypes and default args - Confirm: Add onConfirm and onCancel handlers, add isShow to all story args - InputNumber: Add onChange handler and fix story type assertions - RadioCard: Fix story type assertions for custom render stories - SearchInput: Add onChange to argTypes, args, and individual stories - Select: Add onSelect handler and items prop to stories - Slider: Add onChange handler and fix story type assertions - TagInput: Add onChange to argTypes and default args - Textarea: Add value prop and fix story type assertions Additional fixes: - chat/answer: Use WorkflowRunningStatus enum instead of string literal - voice-input: Fix Array.fill() call with explicit argument - storybook/main: Remove unused fileURLToPath and __dirname imports > [!IMPORTANT] > > 1. Make sure you have read our [contribution guidelines](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) > 1. Ensure there is an associated issue and you have been assigned to it > 1. Use the correct syntax to link this PR: `Fixes #<issue number>`. ## Summary fix #27185 ## Primary Fix: Add Required Event Handlers to Storybook Stories ### 1. **AutoHeightTextarea** (auto-height-textarea/index.stories.tsx) - ✅ Add `onChange` configuration to `argTypes` - ✅ Add default `onChange` handler to meta `args` ### 2. **Confirm** (confirm/index.stories.tsx) - ✅ Add `onConfirm` and `onCancel` handlers to meta `args` - ✅ Add missing `isShow: false` property to all stories ### 3. **InputNumber** (input-number/index.stories.tsx) - ✅ Add default `onChange` handler to meta `args` - ✅ Add `parameters: { controls: { disable: true } }` and type assertions to all custom render stories ### 4. **RadioCard** (radio-card/index.stories.tsx) - ✅ Add `parameters: { controls: { disable: true } }` and `as unknown as Story` type assertions to all custom render stories ### 5. **SearchInput** (search-input/index.stories.tsx) - ✅ Add `onChange` configuration to `argTypes` - ✅ Add default `onChange` handler to meta `args` - ✅ Add missing `value` and `onChange` properties to some stories - ✅ Add type assertions to all custom render stories ### 6. **Select** (select/index.stories.tsx) - ✅ Add default `onSelect` handler to meta `args` - ✅ Add missing `items: []` property to all simple stories - ✅ Add `parameters: { controls: { disable: true } }` and type assertions to all custom render stories ### 7. **Slider** (slider/index.stories.tsx) - ✅ Add default `onChange` handler to meta `args` - ✅ Add `parameters: { controls: { disable: true } }` and type assertions to all custom render stories ### 8. **TagInput** (tag-input/index.stories.tsx) - ✅ Add `onChange` configuration to `argTypes` - ✅ Add default `onChange` handler to meta `args` - ✅ Add `parameters: { controls: { disable: true } }` and type assertions to all custom render stories ### 9. **Textarea** (textarea/index.stories.tsx) - ✅ Add missing `value: ''` property to multiple stories - ✅ Add `parameters: { controls: { disable: true } }` and type assertions to all custom render stories ### 10. **Other Fixes** - ✅ **chat/answer/index.stories.tsx**: Use `WorkflowRunningStatus.Succeeded` enum instead of string literal `'succeeded'` - ✅ **voice-input/index.stories.tsx**: Fix `Array.fill()` call from `.fill()` to `.fill(0)` - ✅ **.storybook/main.ts**: Remove unused `fileURLToPath` and `__dirname` imports ## Statistics - **Files modified**: 12 files - **Lines added**: +189 - **Lines deleted**: -62 - **Net change**: +127 lines <!-- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. --> ## Screenshots | Before | After | |--------|-------| | ... | ... | | ... |<img width="1880" height="944" alt="CleanShot 2025-10-21 at 15 20 29" src="https://github.com/user-attachments/assets/85e140d3-bcd3-4f63-af59-96122eb174b5" />| ## Checklist - [ ] This change requires a documentation update, included: [Dify Document](https://github.com/langgenius/dify-docs) - [x] I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!) - [x] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change. - [x] I've updated the documentation accordingly. - [x] I ran `dev/reformat`(backend) and `cd web && npx lint-staged`(frontend) to appease the lint gods
yindo added the pull-request label 2026-02-21 20:49:59 -05:00
yindo closed this issue 2026-02-21 20:49:59 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#31708