Skip to content

Commit

Permalink
ToolbarButton: Always keep focusable when disabled (#63102)
Browse files Browse the repository at this point in the history
* ToolbarButton: Always keep focusable when disabled

* Omit `__experimentalIsFocusable` from TS types

* Fixup

* Add changelog

* Clarify deprecation comment

Co-authored-by: Marco Ciampini <marco.ciampo@gmail.com>

---------

Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: tyxla <tyxla@git.wordpress.org>
Co-authored-by: jeryj <jeryj@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
  • Loading branch information
6 people authored Jul 4, 2024
1 parent 307a0f7 commit 9d4176c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
### Enhancements

- `ToolbarButton`: Deprecate `isDisabled` prop and merge with `disabled` ([#63101](https://github.com/WordPress/gutenberg/pull/63101)).
- `ToolbarButton`: Always keep focusable when disabled ([#63102](https://github.com/WordPress/gutenberg/pull/63102)).

### Internal

Expand Down
8 changes: 6 additions & 2 deletions packages/components/src/toolbar/toolbar-button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Button from '../../button';
import ToolbarItem from '../toolbar-item';
import ToolbarContext from '../toolbar-context';
import ToolbarButtonContainer from './toolbar-button-container';
import type { ToolbarButtonProps } from './types';
import type { ToolbarButtonDeprecatedProps, ToolbarButtonProps } from './types';
import type { WordPressComponentProps } from '../../context';

function useDeprecatedProps( {
Expand All @@ -30,7 +30,11 @@ function useDeprecatedProps( {
}

function UnforwardedToolbarButton(
props: WordPressComponentProps< ToolbarButtonProps, typeof Button, false >,
props: Omit<
WordPressComponentProps< ToolbarButtonProps, typeof Button, false >,
'__experimentalIsFocusable' // ToolbarButton will always be focusable even when disabled.
> &
ToolbarButtonDeprecatedProps,
ref: ForwardedRef< any >
) {
const {
Expand Down
10 changes: 10 additions & 0 deletions packages/components/src/toolbar/toolbar-button/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ export type ToolbarButtonProps = {
title?: string;
};

export type ToolbarButtonDeprecatedProps = {
/**
* Whether to keep the button focusable when disabled.
*
* @deprecated ToolbarButton will always be focusable even when disabled.
* @ignore
*/
__experimentalIsFocusable?: boolean;
};

export type ToolbarButtonContainerProps = {
/**
* Children to be rendered inside the button container.
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/toolbar/toolbar-item/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ function ToolbarItem(

return (
<Ariakit.ToolbarItem
accessibleWhenDisabled
{ ...allProps }
store={ accessibleToolbarStore }
render={ render }
Expand Down

1 comment on commit 9d4176c

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 9d4176c.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9792960324
📝 Reported issues:

Please sign in to comment.