Skip to content

Commit

Permalink
ToolbarButton: Always keep focusable when disabled (WordPress#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 <[email protected]>

---------

Co-authored-by: mirka <[email protected]>
Co-authored-by: ciampo <[email protected]>
Co-authored-by: tyxla <[email protected]>
Co-authored-by: jeryj <[email protected]>
Co-authored-by: t-hamano <[email protected]>
  • 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

0 comments on commit 9d4176c

Please sign in to comment.