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

Replace __experimentalIsFocusable with accessibleWhenDisabled #63107

Merged
merged 3 commits into from
Jul 4, 2024
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
4 changes: 2 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ const restrictedSyntax = [
const restrictedSyntaxComponents = [
{
selector:
'JSXOpeningElement[name.name="Button"]:not(:has(JSXAttribute[name.name="__experimentalIsFocusable"])) JSXAttribute[name.name="disabled"]',
'JSXOpeningElement[name.name="Button"]:not(:has(JSXAttribute[name.name="accessibleWhenDisabled"])) JSXAttribute[name.name="disabled"]',
message:
'`disabled` used without the `__experimentalIsFocusable` prop. Disabling a control without maintaining focusability can cause accessibility issues, by hiding their presence from screen reader users, or preventing focus from returning to a trigger element. (Ignore this error if you truly mean to disable.)',
'`disabled` used without the `accessibleWhenDisabled` prop. Disabling a control without maintaining focusability can cause accessibility issues, by hiding their presence from screen reader users, or preventing focus from returning to a trigger element. (Ignore this error if you truly mean to disable.)',
},
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function DownloadableBlockListItem( { composite, item, onClick } ) {
<CompositeItem
render={
<Button
__experimentalIsFocusable
accessibleWhenDisabled
type="button"
role="option"
className="block-directory-downloadable-block-list-item"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default function InstallButton( { attributes, block, clientId } ) {
}
} )
}
__experimentalIsFocusable
accessibleWhenDisabled
disabled={ isInstallingBlock }
isBusy={ isInstallingBlock }
variant="primary"
Expand Down
2 changes: 1 addition & 1 deletion packages/block-editor/src/components/block-mover/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ const BlockMoverButton = forwardRef(
{ ...props }
onClick={ isDisabled ? null : onClick }
disabled={ isDisabled }
__experimentalIsFocusable
accessibleWhenDisabled
/>
<VisuallyHidden id={ descriptionId }>
{ getBlockMoverDescription(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ const CarouselNavigation = ( {
label={ __( 'Previous pattern' ) }
onClick={ handlePrevious }
disabled={ activeSlide === 0 }
__experimentalIsFocusable
accessibleWhenDisabled
/>
<Button
icon={ chevronRight }
label={ __( 'Next pattern' ) }
onClick={ handleNext }
disabled={ activeSlide === totalSlides - 1 }
__experimentalIsFocusable
accessibleWhenDisabled
/>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default function Pagination( {
onClick={ () => changePage( 1 ) }
disabled={ currentPage === 1 }
aria-label={ __( 'First page' ) }
__experimentalIsFocusable
accessibleWhenDisabled
>
<span>«</span>
</Button>
Expand All @@ -51,7 +51,7 @@ export default function Pagination( {
onClick={ () => changePage( currentPage - 1 ) }
disabled={ currentPage === 1 }
aria-label={ __( 'Previous page' ) }
__experimentalIsFocusable
accessibleWhenDisabled
>
<span>‹</span>
</Button>
Expand All @@ -74,7 +74,7 @@ export default function Pagination( {
onClick={ () => changePage( currentPage + 1 ) }
disabled={ currentPage === numPages }
aria-label={ __( 'Next page' ) }
__experimentalIsFocusable
accessibleWhenDisabled
>
<span>›</span>
</Button>
Expand All @@ -84,7 +84,7 @@ export default function Pagination( {
disabled={ currentPage === numPages }
aria-label={ __( 'Last page' ) }
size="default"
__experimentalIsFocusable
accessibleWhenDisabled
>
<span>»</span>
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export default function LinkPreview( {
isEmptyURL || showIconLabels ? '' : ': ' + value.url
) }
ref={ ref }
__experimentalIsFocusable
accessibleWhenDisabled
disabled={ isEmptyURL }
size="compact"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function ConvertToLinksModal( { onClick, onClose, disabled } ) {
</Button>
<Button
variant="primary"
__experimentalIsFocusable
accessibleWhenDisabled
disabled={ disabled }
onClick={ onClick }
>
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/page-list/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ export default function PageListEdit( {
<p>{ convertDescription }</p>
<Button
variant="primary"
__experimentalIsFocusable
accessibleWhenDisabled
disabled={ ! hasResolvedPages }
onClick={ convertToNavigationLinks }
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default function TitleModal( { areaLabel, onClose, onSubmit } ) {
<Button
variant="primary"
type="submit"
__experimentalIsFocusable
accessibleWhenDisabled
disabled={ ! title.length }
>
{ __( 'Create' ) }
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/autocomplete/autocompleter-ui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function ListBox( {
id={ `components-autocomplete-item-${ instanceId }-${ option.key }` }
role="option"
aria-selected={ index === selectedIndex }
__experimentalIsFocusable
accessibleWhenDisabled
disabled={ option.isDisabled }
className={ clsx(
'components-autocomplete__result',
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/button/stories/e2e/index.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const VariantStates: StoryFn< typeof Button > = (
{ ...props }
variant={ variant }
disabled
__experimentalIsFocusable
accessibleWhenDisabled
/>
<Button { ...props } variant={ variant } isBusy />
<Button { ...props } variant={ variant } isDestructive />
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/button/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ describe( 'Button', () => {
} );

it( 'should not break when the legacy __experimentalIsFocusable prop is passed', () => {
// eslint-disable-next-line no-restricted-syntax
render( <Button disabled __experimentalIsFocusable /> );
const button = screen.getByRole( 'button' );

Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/dropdown-menu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ function UnconnectedDropdownMenu( dropdownMenuProps: DropdownMenuProps ) {
? control.role
: 'menuitem'
}
__experimentalIsFocusable
accessibleWhenDisabled
disabled={ control.isDisabled }
>
{ control.title }
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/font-size-picker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ const UnforwardedFontSizePicker = (
<FlexItem>
<Button
disabled={ isDisabled }
__experimentalIsFocusable
accessibleWhenDisabled
onClick={ () => {
onChange?.( undefined );
} }
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/range-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ function UnforwardedRangeControl(
<Button
className="components-range-control__reset"
// If the RangeControl itself is disabled, the reset button shouldn't be in the tab sequence.
__experimentalIsFocusable={ ! disabled }
accessibleWhenDisabled={ ! disabled }
disabled={ disabled || value === undefined }
variant="secondary"
size="small"
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/toolbar/toolbar-button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function UnforwardedToolbarButton(
className
) }
isPressed={ isActive }
__experimentalIsFocusable
accessibleWhenDisabled
data-toolbar-item
{ ...extraProps }
{ ...restProps }
Expand Down
2 changes: 1 addition & 1 deletion packages/dataviews/src/add-filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function AddFilter(
<DropdownMenu
trigger={
<Button
__experimentalIsFocusable
accessibleWhenDisabled
size="compact"
className="dataviews-filters-button"
variant="tertiary"
Expand Down
2 changes: 1 addition & 1 deletion packages/dataviews/src/item-actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ function CompactItemActions< Item >( {
size="compact"
icon={ moreVertical }
label={ __( 'Actions' ) }
__experimentalIsFocusable
accessibleWhenDisabled
disabled={ ! actions.length }
className="dataviews-all-actions-button"
/>
Expand Down
4 changes: 2 additions & 2 deletions packages/dataviews/src/pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const Pagination = memo( function Pagination( {
} )
}
disabled={ currentPage === 1 }
__experimentalIsFocusable
accessibleWhenDisabled
label={ __( 'Previous page' ) }
icon={ chevronLeft }
showTooltip
Expand All @@ -102,7 +102,7 @@ const Pagination = memo( function Pagination( {
onChangeView( { ...view, page: currentPage + 1 } )
}
disabled={ currentPage >= totalPages }
__experimentalIsFocusable
accessibleWhenDisabled
label={ __( 'Next page' ) }
icon={ chevronRight }
showTooltip
Expand Down
2 changes: 1 addition & 1 deletion packages/dataviews/src/reset-filters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default function ResetFilter( {
return (
<Button
disabled={ isDisabled }
__experimentalIsFocusable
accessibleWhenDisabled
size="compact"
variant="tertiary"
className="dataviews-filters__reset-button"
Expand Down
2 changes: 1 addition & 1 deletion packages/dataviews/src/view-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ function ListItem< Item >( {
size="compact"
icon={ moreVertical }
label={ __( 'Actions' ) }
__experimentalIsFocusable
accessibleWhenDisabled
disabled={ ! actions.length }
onKeyDown={ ( event: {
key: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export default function InitPatternModal() {
variant="primary"
type="submit"
disabled={ ! title }
__experimentalIsFocusable
accessibleWhenDisabled
>
{ __( 'Create' ) }
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function CustomFieldsConfirmation( { willEnable } ) {
className="edit-post-preferences-modal__custom-fields-confirmation-button"
variant="secondary"
isBusy={ isReloading }
__experimentalIsFocusable
accessibleWhenDisabled
disabled={ isReloading }
onClick={ () => {
setIsReloading( true );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export default function GlobalStylesSidebar() {
isPressed={
isStyleBookOpened || isRevisionsStyleBookOpened
}
__experimentalIsFocusable
accessibleWhenDisabled
disabled={ shouldClearCanvasContainerView }
onClick={ toggleStyleBook }
size="compact"
Expand All @@ -163,7 +163,7 @@ export default function GlobalStylesSidebar() {
label={ __( 'Revisions' ) }
icon={ backup }
onClick={ toggleRevisions }
__experimentalIsFocusable
accessibleWhenDisabled
disabled={ ! hasRevisions }
isPressed={
isRevisionsOpened || isRevisionsStyleBookOpened
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ function FontCollection( { slug } ) {
disabled={
fontsToInstall.length === 0 || isInstalling
}
__experimentalIsFocusable
accessibleWhenDisabled
>
{ __( 'Install' ) }
</Button>
Expand All @@ -455,7 +455,7 @@ function FontCollection( { slug } ) {
size="compact"
onClick={ () => setPage( 1 ) }
disabled={ page === 1 }
__experimentalIsFocusable
accessibleWhenDisabled
>
<span>«</span>
</Button>
Expand All @@ -464,7 +464,7 @@ function FontCollection( { slug } ) {
size="compact"
onClick={ () => setPage( page - 1 ) }
disabled={ page === 1 }
__experimentalIsFocusable
accessibleWhenDisabled
>
<span>‹</span>
</Button>
Expand Down Expand Up @@ -514,7 +514,7 @@ function FontCollection( { slug } ) {
size="compact"
onClick={ () => setPage( page + 1 ) }
disabled={ page === totalPages }
__experimentalIsFocusable
accessibleWhenDisabled
>
<span>›</span>
</Button>
Expand All @@ -523,7 +523,7 @@ function FontCollection( { slug } ) {
size="compact"
onClick={ () => setPage( totalPages ) }
disabled={ page === totalPages }
__experimentalIsFocusable
accessibleWhenDisabled
>
<span>»</span>
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ function InstalledFonts() {
saveFontFamilies( fontFamilies );
} }
disabled={ ! fontFamiliesHasChanges }
__experimentalIsFocusable
accessibleWhenDisabled
>
{ __( 'Update' ) }
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ function RevisionsButtons( {
>
<Button
className="edit-site-global-styles-screen-revisions__revision-button"
__experimentalIsFocusable
accessibleWhenDisabled
disabled={ isSelected }
onClick={ () => {
onChange( revision );
Expand Down
8 changes: 4 additions & 4 deletions packages/edit-site/src/components/pagination/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default function Pagination( {
<Button
variant={ buttonVariant }
onClick={ () => changePage( 1 ) }
__experimentalIsFocusable
accessibleWhenDisabled
disabled={ disabled || currentPage === 1 }
label={ __( 'First page' ) }
icon={ previous }
Expand All @@ -56,7 +56,7 @@ export default function Pagination( {
<Button
variant={ buttonVariant }
onClick={ () => changePage( currentPage - 1 ) }
__experimentalIsFocusable
accessibleWhenDisabled
disabled={ disabled || currentPage === 1 }
label={ __( 'Previous page' ) }
icon={ chevronLeft }
Expand All @@ -75,7 +75,7 @@ export default function Pagination( {
<Button
variant={ buttonVariant }
onClick={ () => changePage( currentPage + 1 ) }
__experimentalIsFocusable
accessibleWhenDisabled
disabled={ disabled || currentPage === numPages }
label={ __( 'Next page' ) }
icon={ chevronRight }
Expand All @@ -84,7 +84,7 @@ export default function Pagination( {
<Button
variant={ buttonVariant }
onClick={ () => changePage( numPages ) }
__experimentalIsFocusable
accessibleWhenDisabled
disabled={ disabled || currentPage === numPages }
label={ __( 'Last page' ) }
icon={ next }
Expand Down
2 changes: 1 addition & 1 deletion packages/edit-site/src/components/save-panel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export default function SavePanel() {
onClick={ () => setIsSaveViewOpened( true ) }
aria-haspopup="dialog"
disabled={ disabled }
__experimentalIsFocusable
accessibleWhenDisabled
>
{ __( 'Open save panel' ) }
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default function RenameModal( { menuTitle, onClose, onSave } ) {

<Button
__next40pxDefaultSize
__experimentalIsFocusable
accessibleWhenDisabled
disabled={ ! isEditedMenuTitleValid }
variant="primary"
type="submit"
Expand Down
Loading
Loading