Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ToolbarButton: Always keep focusable when disabled #63102

Merged
merged 5 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
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.
mirka marked this conversation as resolved.
Show resolved Hide resolved
> &
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.
mirka marked this conversation as resolved.
Show resolved Hide resolved
* @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
Copy link
Member Author

@mirka mirka Jul 3, 2024

Choose a reason for hiding this comment

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

I don't foresee a need for it, but technically a consumer can override this by passing accessibleWhenDisabled={ false }. This is currently undocumented on our end, but we could document it if it ever becomes a need.

{ ...allProps }
store={ accessibleToolbarStore }
render={ render }
Expand Down
Loading