Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
- `SearchControl`: Move search icon to prefix position ([#71984](https://github.com/WordPress/gutenberg/pull/71984)).
- `SearchControl`: Flip search icon depending on placement ([#72070](https://github.com/WordPress/gutenberg/pull/72070)).
- `SearchControl`: Normalize styles ([#72072](https://github.com/WordPress/gutenberg/pull/72072)).
- `CheckboxControl`, `RadioControl`, `ToggleControl` (`FormToggle`): Ensure elements are focused when clicked in Safari ([#72115](https://github.com/WordPress/gutenberg/pull/72115)).

### Bug Fixes

- `ValidatedCheckboxControl`, `ValidatedRadioControl`, `ValidatedToggleControl`: Fix issue where validation may not be triggered in Safari when elements are toggled by clicking ([#72115](https://github.com/WordPress/gutenberg/pull/72115)).

### Internal

Expand Down
7 changes: 7 additions & 0 deletions packages/components/src/checkbox-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export function CheckboxControl(
help,
id: idProp,
onChange,
onClick,
...additionalProps
} = props;

Expand Down Expand Up @@ -118,6 +119,12 @@ export function CheckboxControl(
onChange={ onChangeValue }
checked={ checked }
aria-describedby={ !! help ? id + '__help' : undefined }
onClick={ ( event ) => {
// Compat code for Safari to ensure that the checkbox is focused when clicked.
event.currentTarget.focus();

onClick?.( event );
} }
{ ...additionalProps }
/>
{ showIndeterminateIcon ? (
Expand Down
7 changes: 7 additions & 0 deletions packages/components/src/form-toggle/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ function UnforwardedFormToggle(
id,
disabled,
onChange = noop,
onClick,
...additionalProps
} = props;
const wrapperClasses = clsx( 'components-form-toggle', className, {
Expand All @@ -43,6 +44,12 @@ function UnforwardedFormToggle(
checked={ checked }
onChange={ onChange }
disabled={ disabled }
onClick={ ( event ) => {
// Compat code for Safari to ensure that the toggle is focused when clicked.
event.currentTarget.focus();

onClick?.( event );
} }
{ ...additionalProps }
ref={ ref }
/>
Expand Down
7 changes: 7 additions & 0 deletions packages/components/src/radio-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export function RadioControl(
selected,
help,
onChange,
onClick,
hideLabelFromVision,
options = [],
id: preferredId,
Expand Down Expand Up @@ -121,6 +122,12 @@ export function RadioControl(
? generateOptionDescriptionId( id, index )
: undefined
}
onClick={ ( event ) => {
// Compat code for Safari to ensure that the radio is focused when clicked.
event.currentTarget.focus();

onClick?.( event );
} }
{ ...additionalProps }
/>
<label
Expand Down
Loading