fix(Button): handle invalid React children for icon props and add Lucid icon picker#7
Closed
garrity-miepub wants to merge 2 commits intomainfrom
Closed
fix(Button): handle invalid React children for icon props and add Lucid icon picker#7garrity-miepub wants to merge 2 commits intomainfrom
garrity-miepub wants to merge 2 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the Button component to be more resilient when icon props receive invalid React children, and enhances the Storybook Button stories with a Lucide icon picker to preview left/right icons.
Changes:
- Guard
leftIcon/rightIconrendering withReact.isValidElementto avoid invalid-child runtime errors. - Add Storybook controls for selecting Lucide icons for
leftIconandrightIcon. - Refresh icon-related stories to use Lucide icons (left, right, and both).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/components/Button/Button.tsx | Adds validation before rendering icon props to prevent invalid React child rendering. |
| src/components/Button/Button.stories.tsx | Adds a Lucide icon registry + Storybook controls for icon selection and new icon stories. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Tighten icon prop types to match runtime behavior - Changed leftIcon/rightIcon from React.ReactNode to React.ReactElement | null - This aligns the type signature with the React.isValidElement() check - Prevents silent dropping of strings/numbers/component types - Remove unused React import from Button.stories.tsx - JSX transform (react-jsx) handles React automatically - Fixes @typescript-eslint/no-unused-vars lint error - Fix iconRegistry type safety - Changed type from Record<string, LucideIcon> to Record<string, LucideIcon | undefined> - Removed unsafe 'as unknown as LucideIcon' cast for None entry - Now properly types None: undefined without defeating type-safety
Deploying ui with
|
| Latest commit: |
5e493de
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://b996d532.ui-6d0.pages.dev |
| Branch Preview URL: | https://feature-button-updates.ui-6d0.pages.dev |
garrity-miepub
added a commit
that referenced
this pull request
Mar 24, 2026
- Replace hand-rolled menu (useState, useRef, useEffect click-outside, useEscapeKey, custom role=menu div, raw button elements) with the existing Dropdown/DropdownItem/DropdownSeparator components - Gets focus management, ARIA attributes, keyboard nav, dark mode, and consistent styling for free - Add DropdownSeparator between normal and destructive actions - Remove unused imports: React, cn, useEscapeKey - Net reduction: ~65 lines of custom code Addresses Copilot review comment #7 on PR #146 (a11y regression).
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.
Added lucid icon options to the button, and dropdowns to preview them on the component
button-updates.mov