Skip to content

Commit

Permalink
Add type="button" to vanilla <button> elements (#55125)
Browse files Browse the repository at this point in the history
* Adding `type="button` to buttons as needed
* Updating test snapshots
* Updating `CHANGELOG.md`
  • Loading branch information
Andrew Hayward authored Oct 11, 2023
1 parent a7d0c6f commit e125803
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ exports[`ColorPaletteControl matches the snapshot 1`] = `
aria-label="Custom color picker. The currently selected color is called "red" and has a value of "#f00"."
class="components-color-palette__custom-color-button"
style="background: rgb(255, 0, 0);"
type="button"
/>
<div
class="components-flex components-h-stack components-v-stack components-color-palette__custom-color-text-wrapper emotion-12 emotion-5"
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/page-list-item/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export default function PageListItemEdit( { context, attributes } ) {
{ hasChildren && context.openSubmenusOnClick ? (
<>
<button
type="button"
className="wp-block-navigation-item__content wp-block-navigation-submenu__toggle"
aria-expanded="false"
>
Expand All @@ -90,6 +91,7 @@ export default function PageListItemEdit( { context, attributes } ) {
<button
className="wp-block-navigation-item__content wp-block-navigation-submenu__toggle wp-block-page-list__submenu-icon wp-block-navigation__submenu-icon"
aria-expanded="false"
type="button"
>
<ItemSubmenuIcon />
</button>
Expand Down
3 changes: 2 additions & 1 deletion packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Enhancements

- `Notice`: Remove margins from `Notice` component ([#54800](https://github.com/WordPress/gutenberg/pull/54800)).
- `ColorPalette`/`ToggleGroupControl/ToggleGroupControlOptionBase`: add `type="button"` attribute to native `<button>`s ([#55125](https://github.com/WordPress/gutenberg/pull/55125)).

### Bug Fix

Expand Down Expand Up @@ -52,7 +53,7 @@

### Experimental

- Introduce `Tabs`, an experimental v2 of `TabPanel`: ([#53960](https://github.com/WordPress/gutenberg/pull/53960)).
- Introduce `Tabs`, an experimental v2 of `TabPanel`: ([#53960](https://github.com/WordPress/gutenberg/pull/53960)).

## 25.8.0 (2023-09-20)

Expand Down
1 change: 1 addition & 0 deletions packages/components/src/color-palette/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ function UnforwardedColorPalette(
style={ {
background: value,
} }
type="button"
/>
<VStack
className="components-color-palette__custom-color-text-wrapper"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ exports[`ToggleGroupControl controlled should render correctly with icons 1`] =
data-wp-component="ToggleGroupControlOptionBase"
id="toggle-group-control-as-radio-group-8-20"
role="radio"
type="button"
>
<div
class="emotion-13 emotion-14"
Expand Down Expand Up @@ -292,6 +293,7 @@ exports[`ToggleGroupControl controlled should render correctly with icons 1`] =
data-wp-component="ToggleGroupControlOptionBase"
id="toggle-group-control-as-radio-group-8-21"
role="radio"
type="button"
>
<div
class="emotion-13 emotion-14"
Expand Down Expand Up @@ -500,6 +502,7 @@ exports[`ToggleGroupControl controlled should render correctly with text options
data-wp-component="ToggleGroupControlOptionBase"
id="toggle-group-control-as-radio-group-7-18"
role="radio"
type="button"
>
<div
class="emotion-13 emotion-14"
Expand All @@ -521,6 +524,7 @@ exports[`ToggleGroupControl controlled should render correctly with text options
data-wp-component="ToggleGroupControlOptionBase"
id="toggle-group-control-as-radio-group-7-19"
role="radio"
type="button"
>
<div
class="emotion-13 emotion-14"
Expand Down Expand Up @@ -796,6 +800,7 @@ exports[`ToggleGroupControl uncontrolled should render correctly with icons 1`]
data-wp-component="ToggleGroupControlOptionBase"
id="toggle-group-control-as-radio-group-1-2"
role="radio"
type="button"
>
<div
class="emotion-13 emotion-14"
Expand Down Expand Up @@ -833,6 +838,7 @@ exports[`ToggleGroupControl uncontrolled should render correctly with icons 1`]
data-wp-component="ToggleGroupControlOptionBase"
id="toggle-group-control-as-radio-group-1-3"
role="radio"
type="button"
>
<div
class="emotion-13 emotion-14"
Expand Down Expand Up @@ -1035,6 +1041,7 @@ exports[`ToggleGroupControl uncontrolled should render correctly with text optio
data-wp-component="ToggleGroupControlOptionBase"
id="toggle-group-control-as-radio-group-0-0"
role="radio"
type="button"
>
<div
class="emotion-13 emotion-14"
Expand All @@ -1056,6 +1063,7 @@ exports[`ToggleGroupControl uncontrolled should render correctly with text optio
data-wp-component="ToggleGroupControlOptionBase"
id="toggle-group-control-as-radio-group-0-1"
role="radio"
type="button"
>
<div
class="emotion-13 emotion-14"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ function ToggleGroupControlOptionBase(
<Ariakit.Radio
render={
<button
type="button"
{ ...commonProps }
onFocus={ ( event ) => {
onFocusProp?.( event );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export default function ResizeHandle( {
aria-label={ __( 'Drag to resize' ) }
aria-describedby={ `resizable-editor__resize-help-${ direction }` }
onKeyDown={ handleKeyDown }
type="button"
/>
<VisuallyHidden
id={ `resizable-editor__resize-help-${ direction }` }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ function GridItem( { categoryId, item, ...props } ) {
// Even though still incomplete, passing ids helps performance.
// @see https://reakit.io/docs/composite/#performance.
id={ `edit-site-patterns-${ item.name }` }
type="button"
{ ...props }
onClick={
item.type !== PATTERN_TYPES.theme ? onClick : undefined
Expand Down

0 comments on commit e125803

Please sign in to comment.