-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SvgIcon] Fix passing an ownerState to SvgIcon changes the font size #34429
Merged
siriwatknp
merged 5 commits into
mui:master
from
ZeeshanTamboli:issue/34056-ownerState-to-svgicon
Sep 26, 2022
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c0dc777
add tests
ZeeshanTamboli 6a728fd
fix ownerState logic
ZeeshanTamboli 825d7eb
Merge branch 'master' into issue/34056-ownerState-to-svgicon
ZeeshanTamboli 92dc8c8
add missing rem unit
ZeeshanTamboli 5e121bb
yarn docs:api
ZeeshanTamboli File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,7 +47,7 @@ const SvgIconRoot = styled('svg', { | |
inherit: 'inherit', | ||
small: theme.typography?.pxToRem?.(20) || '1.25rem', | ||
medium: theme.typography?.pxToRem?.(24) || '1.5rem', | ||
large: theme.typography?.pxToRem?.(35) || '2.1875', | ||
large: theme.typography?.pxToRem?.(35) || '2.1875rem', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
}[ownerState.fontSize], | ||
// TODO v5 deprecate, v6 remove for sx | ||
color: | ||
|
@@ -96,14 +96,14 @@ const SvgIcon = React.forwardRef(function SvgIcon(inProps, ref) { | |
<SvgIconRoot | ||
as={component} | ||
className={clsx(classes.root, className)} | ||
ownerState={ownerState} | ||
focusable="false" | ||
color={htmlColor} | ||
aria-hidden={titleAccess ? undefined : true} | ||
role={titleAccess ? 'img' : undefined} | ||
ref={ref} | ||
{...more} | ||
{...other} | ||
ownerState={ownerState} | ||
> | ||
{children} | ||
{titleAccess ? <title>{titleAccess}</title> : null} | ||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,8 @@ export interface SvgIconClasses { | |
fontSizeInherit: string; | ||
/** Styles applied to the root element if `fontSize="small"`. */ | ||
fontSizeSmall: string; | ||
/** Styles applied to the root element if `fontSize="medium"`. */ | ||
fontSizeMedium: string; | ||
Comment on lines
+20
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not related to the issue, but found this class was missing in types. |
||
/** Styles applied to the root element if `fontSize="large"`. */ | ||
fontSizeLarge: string; | ||
} | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a real use case to test this one? I ask this because I plan to change the test file to
.tsx
and I am pretty sure that theSvgIcon
does not supportownerState
prop.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the icon slot in MUI X Pickers does pass
ownerState
for CSS customization based on ownerState. Also, you can see it in the before and after CodeSandboxes in the description, so we need it.You can use
// @ts-expect-error
comment.