Skip to content

Commit

Permalink
fix: Checkbox's label shouldn't have a pointer cursor when disabled (#…
Browse files Browse the repository at this point in the history
…25018)

* Use the default cursor (not pointer) on the label when the checkbox is disabled
* Simplify the styles controlling the padding between the checkbox and label
  • Loading branch information
behowell authored Sep 30, 2022
1 parent d14f81c commit d821905
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: Checkbox's label shouldn't have a pointer cursor when disabled",
"packageName": "@fluentui/react-checkbox",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ const useInputStyles = makeStyles({
cursor: 'default',

[`& ~ .${checkboxClassNames.label}`]: {
cursor: 'default',
color: tokens.colorNeutralForegroundDisabled,
'@media (forced-colors: active)': {
color: 'GrayText',
Expand Down Expand Up @@ -156,13 +157,6 @@ const useInputStyles = makeStyles({
large: {
width: `calc(${indicatorSizeLarge} + 2 * ${tokens.spacingHorizontalS})`,
},

labelMedium: {
width: `calc(${indicatorSizeMedium} + ${tokens.spacingHorizontalS})`,
},
labelLarge: {
width: `calc(${indicatorSizeLarge} + ${tokens.spacingHorizontalS})`,
},
});

const useIndicatorStyles = makeStyles({
Expand All @@ -183,13 +177,6 @@ const useIndicatorStyles = makeStyles({
pointerEvents: 'none',
},

labelBefore: {
marginLeft: 0,
},
labelAfter: {
marginRight: 0,
},

medium: {
fontSize: '12px',
height: indicatorSizeMedium,
Expand All @@ -216,10 +203,10 @@ const useLabelStyles = makeStyles({
},

before: {
paddingRight: tokens.spacingHorizontalM,
paddingRight: tokens.spacingHorizontalXS,
},
after: {
paddingLeft: tokens.spacingHorizontalM,
paddingLeft: tokens.spacingHorizontalXS,
},

// Use a (negative) margin to account for the difference between the indicator's height and the label's line height.
Expand All @@ -241,15 +228,13 @@ export const useCheckboxStyles_unstable = (state: CheckboxState): CheckboxState
const rootStyles = useRootStyles();
state.root.className = mergeClasses(checkboxClassNames.root, rootStyles.base, state.root.className);

const { label, labelPosition, shape, size } = state;
const { labelPosition, shape, size } = state;

const inputStyles = useInputStyles();
state.input.className = mergeClasses(
checkboxClassNames.input,
inputStyles.base,
inputStyles[size],
label && size === 'medium' && inputStyles.labelMedium,
label && size === 'large' && inputStyles.labelLarge,
inputStyles[labelPosition],
state.input.className,
);
Expand All @@ -260,8 +245,6 @@ export const useCheckboxStyles_unstable = (state: CheckboxState): CheckboxState
checkboxClassNames.indicator,
indicatorStyles.base,
indicatorStyles[size],
label && labelPosition === 'before' && indicatorStyles.labelBefore,
label && labelPosition === 'after' && indicatorStyles.labelAfter,
shape === 'circular' && indicatorStyles.circular,
state.indicator.className,
);
Expand Down

0 comments on commit d821905

Please sign in to comment.