fix(mui): respect custom startIcon when hideText is true on all button components#7345
Open
tysoncung wants to merge 1 commit intorefinedev:mainfrom
Open
fix(mui): respect custom startIcon when hideText is true on all button components#7345tysoncung wants to merge 1 commit intorefinedev:mainfrom
tysoncung wants to merge 1 commit intorefinedev:mainfrom
Conversation
…n components When hideText=true, MUI button components (Show, Edit, Delete, Clone, Create, List, Refresh, Save, Export, Import) ignored any custom startIcon passed via props, always rendering the hardcoded default icon as children. If a user also passed startIcon, it would render as the MUI Button startIcon slot AND the default icon would render as children — causing a double-icon display. Fix: Extract startIcon from rest props and use it as the icon content when hideText=true if provided, falling back to the default icon otherwise. When hideText=false and a custom startIcon is provided, use it instead of the default. Fixes refinedev#7343
|
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.
Summary
Fixes #7343
When
hideText=true, all MUI button components (ShowButton,EditButton,DeleteButton,CloneButton,CreateButton,ListButton,RefreshButton,SaveButton,ExportButton,ImportButton) ignored any customstartIconpassed via props and always rendered the hardcoded default icon as children. If a user also passedstartIconthrough rest props, it would render as the MUI ButtonstartIconslot AND the default icon would render as children — causing a double-icon display.Root Cause
The
startIconprop was not extracted from the rest/spread props, so it was passed through to the MUI<Button>component via{...restProps}. Meanwhile, the component always rendered its default icon as children whenhideText=true, resulting in two icons.Fix
For all 10 affected button components:
startIconfrom the rest/spread propshideText=true: renderstartIcon ?? defaultIconas the button's children (nostartIconprop on the Button itself)hideText=false: usestartIcon ?? <DefaultIcon />as the Button'sstartIconpropThis ensures a user-provided
startIconis respected in both modes, with the default icon as fallback.Affected Components
ShowButtonVisibilityOutlinedEditButtonEditOutlinedDeleteButtonDeleteOutlineCloneButtonAddBoxOutlinedCreateButtonAddBoxOutlinedListButtonListOutlinedRefreshButtonRefreshOutlinedSaveButtonSaveOutlinedExportButtonImportExportOutlinedImportButtonImportExportOutlinedTesting
Added MUI-specific tests for
ShowButtoncovering:startIconwithhideText=truerenders only the custom iconhideText=truewith no customstartIconstartIconused instartIconslot whenhideText=false