Skip to content

Commit a49d647

Browse files
remove div for performance
1 parent 001aa89 commit a49d647

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

docs/data/material/components/material-icons/SearchIcons.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,21 +93,20 @@ function selectNode(node) {
9393
selection.addRange(range);
9494
}
9595

96+
const iconWidth = 35;
97+
9698
const StyledIcon = styled('span')(({ theme }) => ({
9799
display: 'inline-flex',
98100
flexDirection: 'column',
99101
color: theme.palette.text.secondary,
100102
margin: '0 4px',
101103
'& > div': {
102-
display: 'flex',
103-
},
104-
'& > div > *': {
105104
flexGrow: 1,
106105
fontSize: '.6rem',
107106
overflow: 'hidden',
108107
textOverflow: 'ellipsis',
109108
textAlign: 'center',
110-
width: 0,
109+
width: `calc(${iconWidth}px + ${theme.spacing(2)} * 2 + 2px)`,
111110
},
112111
}));
113112

@@ -116,6 +115,7 @@ const StyledSvgIcon = styled(SvgIcon)(({ theme }) => ({
116115
cursor: 'pointer',
117116
color: theme.palette.text.primary,
118117
border: '1px solid transparent',
118+
fontSize: iconWidth,
119119
borderRadius: '12px',
120120
transition: theme.transitions.create(['background-color', 'box-shadow'], {
121121
duration: theme.transitions.duration.shortest,
@@ -143,7 +143,9 @@ const handleIconClick = (event) => {
143143
}
144144
};
145145

146-
const handleLabelClick = (event) => selectNode(event.currentTarget);
146+
function handleLabelClick(event) {
147+
selectNode(event.currentTarget);
148+
}
147149

148150
function Icon(props) {
149151
const { icon, onOpenClick } = props;
@@ -157,15 +159,12 @@ function Icon(props) {
157159
>
158160
<StyledSvgIcon
159161
component={icon.Component}
160-
fontSize="large"
161162
tabIndex={-1}
162163
onClick={onOpenClick}
163164
title={icon.importName}
164165
/>
165-
<div>
166-
{/* eslint-disable-next-line jsx-a11y/no-static-element-interactions -- TODO: a11y */}
167-
<div onClick={handleLabelClick}>{icon.importName}</div>
168-
</div>
166+
{/* eslint-disable-next-line jsx-a11y/no-static-element-interactions -- TODO: a11y */}
167+
<div onClick={handleLabelClick}>{icon.importName}</div>
169168
{/* eslint-enable jsx-a11y/click-events-have-key-events */}
170169
</StyledIcon>
171170
);

0 commit comments

Comments
 (0)