Skip to content

Commit

Permalink
Fix mapped ids
Browse files Browse the repository at this point in the history
  • Loading branch information
brookewp committed Jan 3, 2024
1 parent b28c652 commit 7fbbe43
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
6 changes: 3 additions & 3 deletions packages/components/src/box-control/all-input-control.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ export default function AllInputControl( {
setSelectedUnits,
...props
}: BoxControlInputControlProps ) {
const inputId = useInstanceId( AllInputControl, 'box-control-input' );
const generatedId = useInstanceId( AllInputControl, 'box-control-input' );
const inputId = [ generatedId, LABELS.all ].join( '-' );

const allValue = getAllValue( values, selectedUnits, sides );
const hasValues = isValuesDefined( values );
const isMixed = hasValues && isValuesMixed( values, selectedUnits, sides );
Expand Down Expand Up @@ -111,8 +113,6 @@ export default function AllInputControl( {
__nextHasNoMarginBottom
aria-controls={ inputId }
aria-labelledby={ inputId }
hideLabelFromVision
label={ LABELS.all }
onChange={ sliderOnChange }
min={ 0 }
max={ CUSTOM_VALUE_SETTINGS[ parsedUnit ?? 'px' ]?.max ?? 10 }
Expand Down
11 changes: 8 additions & 3 deletions packages/components/src/box-control/axial-input-controls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ export default function AxialInputControls( {
sides,
...props
}: BoxControlInputControlProps ) {
const inputId = useInstanceId( AxialInputControls, 'box-control-input' );
const generatedId = useInstanceId(
AxialInputControls,
`box-control-input`
);

const createHandleOnFocus =
( side: GroupedSide ) =>
( event: React.FocusEvent< HTMLInputElement > ) => {
Expand Down Expand Up @@ -133,6 +137,9 @@ export default function AxialInputControls( {
side === 'vertical'
? selectedUnits.top
: selectedUnits.left;

const inputId = [ generatedId, side ].join( '-' );

return (
<InputWrapper key={ `box-control-${ side }` }>
<FlexedBoxControlIcon side={ side } sides={ sides } />
Expand Down Expand Up @@ -160,8 +167,6 @@ export default function AxialInputControls( {
__nextHasNoMarginBottom
aria-controls={ inputId }
aria-labelledby={ inputId }
hideLabelFromVision
label={ LABELS[ side ] }
onChange={ ( newValue ) =>
handleOnValueChange(
side,
Expand Down
5 changes: 3 additions & 2 deletions packages/components/src/box-control/input-controls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default function BoxInputControls( {
sides,
...props
}: BoxControlInputControlProps ) {
const inputId = useInstanceId( BoxInputControls, 'box-control-input' );
const generatedId = useInstanceId( BoxInputControls, 'box-control-input' );

const createHandleOnFocus =
( side: keyof BoxControlValue ) =>
Expand Down Expand Up @@ -112,6 +112,8 @@ export default function BoxInputControls( {
? parsedUnit
: selectedUnits[ side ];

const inputId = [ generatedId, side ].join( '-' );

return (
<InputWrapper key={ `box-control-${ side }` } expanded>
<FlexedBoxControlIcon side={ side } sides={ sides } />
Expand All @@ -138,7 +140,6 @@ export default function BoxInputControls( {
aria-controls={ inputId }
aria-labelledby={ inputId }
__nextHasNoMarginBottom
hideLabelFromVision
onChange={ ( newValue ) => {
handleOnValueChange(
side,
Expand Down

0 comments on commit 7fbbe43

Please sign in to comment.