-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Update negative values for margins #40653
Conversation
Size Change: +5 B (0%) Total Size: 1.23 MB
ℹ️ View Unchanged
|
@@ -57,7 +57,7 @@ export default function BoxControl( { | |||
resetValues = DEFAULT_VALUES, | |||
allowNegativeValues = false, | |||
} ) { | |||
inputProps = allowNegativeValues ? { min: -Infinity } : defaultInputProps; | |||
inputProps.min = allowNegativeValues ? -Infinity : defaultInputProps.min; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for following up, Justin!
I'm actually wondering about this new prop. If a dev does something like this:
<BoxControl
inputProps={ { min: -10 } }
allowNegativeValues
/>
At first glance this looks correct, but the minimum of -10
is actually being overwritten still with -Infinity
by this code.
There are probably ways to fix that, but then another scenario is something meaningless like:
<BoxControl
inputProps={ { min: 5 } }
allowNegativeValues
/>
I think it might be best not to have two props that can do the same thing. Maybe there's no need for the allowNegativeValues
prop at all, and the BoxControl
used for margin could be simplified to:
<BoxControl
inputProps={ { min: -Infinity } }
/>
It isn't as clean as allowNegativeValues
, but I think it's less likely to cause confusion.
Closing this in favor of #40674. |
What?
Follows up #40464.
Why?
The initial PR had an issue where the
inputProps
could be unusable. See #40464 (comment).How?
This PR set back
inputProps
todefaultInputProps
in theBoxControl()
function, and updates its value toinputProps.min = allowNegativeValues ? -Infinity : defaultInputProps.min;
.Testing Instructions