-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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 HeightControl component to label inputs #63761
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,15 @@ import { space } from '../utils/space'; | |
|
||
const noop = () => {}; | ||
|
||
function useUniqueId( idProp?: string ) { | ||
const id = useInstanceId( | ||
UnforwardedRangeControl, | ||
'inspector-range-control' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder what this component has to do with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that's the instance ID prefix that many components in the package adopt 😓 Not sure how easy it would be to refactor away from it, but probably not in the scope for this PR ( |
||
); | ||
|
||
return idProp || id; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we mean to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had that same question when reviewing the original PR, and at the time we agreed that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, reminder that the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I forgot about it — thank you for pointing it out! |
||
} | ||
|
||
function UnforwardedRangeControl( | ||
props: WordPressComponentProps< RangeControlProps, 'input', false >, | ||
forwardedRef: ForwardedRef< HTMLInputElement > | ||
|
@@ -56,6 +65,7 @@ function UnforwardedRangeControl( | |
disabled = false, | ||
help, | ||
hideLabelFromVision = false, | ||
id: idProp, | ||
initialPosition, | ||
isShiftStepEnabled = true, | ||
label, | ||
|
@@ -123,10 +133,7 @@ function UnforwardedRangeControl( | |
!! marks && 'is-marked' | ||
); | ||
|
||
const id = useInstanceId( | ||
UnforwardedRangeControl, | ||
'inspector-range-control' | ||
); | ||
const id = useUniqueId( idProp ); | ||
const describedBy = !! help ? `${ id }__help` : undefined; | ||
const enableTooltip = hasTooltip !== false && Number.isFinite( value ); | ||
|
||
|
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.
I guess this
for
should have beenhtmlFor
. Getting this in the condole: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.
Yup - I must have let my guard down knowing that this PR had been reviewed before. Thank you for pointing it out