Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Only offer unlink button when multiple sides allowed
  • Loading branch information
aaronrobertshaw committed Apr 19, 2021
commit 123b241c9f9836a49bf6f45d9029e30380abad70
17 changes: 10 additions & 7 deletions packages/components/src/box-control/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ export default function BoxControl( {
} );
const inputValues = values || DEFAULT_VALUES;
const hasInitialValue = isValuesDefined( valuesProp );
const hasOneSide = sides?.length === 1;

const [ isDirty, setIsDirty ] = useState( hasInitialValue );
const [ isLinked, setIsLinked ] = useState(
! hasInitialValue || ! isValuesMixed( inputValues )
! hasInitialValue || ! isValuesMixed( inputValues ) || hasOneSide
);

const [ side, setSide ] = useState( isLinked ? 'all' : 'top' );
Expand Down Expand Up @@ -146,12 +147,14 @@ export default function BoxControl( {
/>
</FlexBlock>
) }
<FlexItem>
<LinkedButton
onClick={ toggleLinked }
isLinked={ isLinked }
/>
</FlexItem>
{ ! hasOneSide && (
<FlexItem>
<LinkedButton
onClick={ toggleLinked }
isLinked={ isLinked }
/>
</FlexItem>
) }
</HeaderControlWrapper>
{ ! isLinked && <InputControls { ...inputControlProps } /> }
</Root>
Expand Down