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

Allow negative values for margin inputs #40464

Merged
merged 4 commits into from
Apr 27, 2022
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
Next Next commit
Use the spacingType property to define when negative margin is accepted
  • Loading branch information
JustinyAhin committed Apr 20, 2022
commit aa2885f76be64e5f2ccf98c4939ec45fae66cf37
1 change: 1 addition & 0 deletions packages/block-editor/src/hooks/margin.js
Original file line number Diff line number Diff line change
@@ -149,6 +149,7 @@ export function MarginEdit( props ) {
units={ units }
allowReset={ false }
splitOnAxis={ splitOnAxis }
spacingType={ __( 'Margin' ) }
/>
</>
),
3 changes: 2 additions & 1 deletion packages/components/src/box-control/index.js
Original file line number Diff line number Diff line change
@@ -58,8 +58,9 @@ export default function BoxControl( {
splitOnAxis = false,
allowReset = true,
resetValues = DEFAULT_VALUES,
spacingType,
JustinyAhin marked this conversation as resolved.
Show resolved Hide resolved
} ) {
inputProps = label === __( 'Margin' ) ? -Infinity : defaultInputProps;
inputProps = spacingType === 'Margin' ? -Infinity : defaultInputProps;
JustinyAhin marked this conversation as resolved.
Show resolved Hide resolved

const [ values, setValues ] = useControlledState( valuesProp, {
fallback: DEFAULT_VALUES,