-
Notifications
You must be signed in to change notification settings - Fork 41
Open
Description
Summary
Fixes the clickMe.click is not a function error in Storybook when rendering Tabs stories (particularly the selectedTab story).
Problem
In src/tabs.ts, the code calls .click() on firstChild without checking if it's actually an element with a click method:
const clickMe = tab.firstChild
// @ts-ignore
if (clickMe) clickMe.click()firstChild returns ChildNode | null, which could be a Text node or Comment node (no .click() method). The @ts-ignore masked the TypeScript error but crashed at runtime.
Solution
Replace the unsafe code with proper type checking:
const clickMe = tab.firstChild as HTMLElement | null
if (clickMe?.click) clickMe.click()Fixes
Closes #490
Testing
- All existing tests pass
- Storybook Tabs stories now render without error
Metadata
Metadata
Assignees
Labels
No labels