Skip to content
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

perf: Don't render Checkbox icon when unchecked #26248

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "perf: Don't render Checkbox icon when unchecked",
"packageName": "@fluentui/react-checkbox",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,7 @@ exports[`Checkbox renders a default state 1`] = `
<div
aria-hidden="true"
class="fui-Checkbox__indicator"
>
<svg
aria-hidden="true"
class=""
fill="currentColor"
height="12"
viewBox="0 0 12 12"
width="12"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M9.76 3.2c.3.29.32.76.04 1.06l-4.25 4.5a.75.75 0 01-1.08.02L2.22 6.53a.75.75 0 011.06-1.06l1.7 1.7L8.7 3.24a.75.75 0 011.06-.04z"
fill="currentColor"
/>
</svg>
</div>
/>
</span>
</div>
`;
Expand Down Expand Up @@ -153,22 +138,7 @@ exports[`Checkbox renders with a label 1`] = `
<div
aria-hidden="true"
class="fui-Checkbox__indicator"
>
<svg
aria-hidden="true"
class=""
fill="currentColor"
height="12"
viewBox="0 0 12 12"
width="12"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M9.76 3.2c.3.29.32.76.04 1.06l-4.25 4.5a.75.75 0 01-1.08.02L2.22 6.53a.75.75 0 011.06-1.06l1.7 1.7L8.7 3.24a.75.75 0 011.06-.04z"
fill="currentColor"
/>
</svg>
</div>
/>
<label
class="fui-Label fui-Checkbox__label"
for="checkbox-1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const useCheckbox_unstable = (props: CheckboxProps, ref: React.Ref<HTMLIn
} else {
checkmarkIcon = size === 'large' ? <Square16Filled /> : <Square12Filled />;
}
} else {
} else if (checked) {
checkmarkIcon = size === 'large' ? <Checkmark16Filled /> : <Checkmark12Filled />;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ const useInputBaseClassName = makeResetStyles({
// This is done so that clicking on that "empty space" still toggles the checkbox.
width: `calc(${indicatorSizeMedium} + 2 * ${tokens.spacingHorizontalS})`,

// When unchecked, hide the the checkmark icon (child of the indicator slot)
[`:not(:checked):not(:indeterminate) ~ .${checkboxClassNames.indicator} > *`]: {
opacity: 0,
},

// Colors for the unchecked state
':enabled:not(:checked):not(:indeterminate)': {
[`& ~ .${checkboxClassNames.label}`]: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,7 @@ exports[`TableSelectionCell renders a default state 1`] = `
<div
aria-hidden="true"
class="fui-Checkbox__indicator"
>
<svg
aria-hidden="true"
class=""
fill="currentColor"
height="12"
viewBox="0 0 12 12"
width="12"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M9.76 3.2c.3.29.32.76.04 1.06l-4.25 4.5a.75.75 0 01-1.08.02L2.22 6.53a.75.75 0 011.06-1.06l1.7 1.7L8.7 3.24a.75.75 0 011.06-.04z"
fill="currentColor"
/>
</svg>
</div>
/>
</span>
</td>
</tr>
Expand Down