Skip to content

Commit

Permalink
Disable units independently of mixed colors & styles
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronrobertshaw committed Oct 4, 2022
1 parent a3e0a71 commit aeb352b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const BorderBoxControl = (
className,
colors,
disableCustomColors,
disableUnits,
enableAlpha,
enableStyle,
hasMixedBorders,
Expand Down Expand Up @@ -100,7 +101,7 @@ const BorderBoxControl = (
<BorderControl
className={ linkedControlClassName }
colors={ colors }
disableUnits={ hasMixedBorders }
disableUnits={ disableUnits }
disableCustomColors={ disableCustomColors }
enableAlpha={ enableAlpha }
enableStyle={ enableStyle }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ export function useBorderBoxControl(
? ( value as Borders )
: getSplitBorders( value as Border | undefined );

// If no numeric width value is set, the unit select will be disabled.
const hasWidthValue = ! isNaN( parseFloat( `${ linkedValue?.width }` ) );

const [ isLinked, setIsLinked ] = useState( ! mixedBorders );
const toggleLinked = () => setIsLinked( ! isLinked );

Expand Down Expand Up @@ -107,6 +110,7 @@ export function useBorderBoxControl(
return {
...otherProps,
className: classes,
disableUnits: mixedBorders && ! hasWidthValue,
hasMixedBorders: mixedBorders,
isLinked,
linkedControlClassName,
Expand Down

0 comments on commit aeb352b

Please sign in to comment.