From b864ca99d3e7b09b1f59b17162b24f0eab0b1307 Mon Sep 17 00:00:00 2001 From: Lena Morita Date: Thu, 4 Jul 2024 07:09:31 +0900 Subject: [PATCH] Replace `__experimentalIsFocusable` with `accessibleWhenDisabled` --- .eslintrc.js | 4 ++-- .../components/downloadable-block-list-item/index.js | 2 +- .../src/plugins/get-install-missing/install-button.js | 2 +- .../block-editor/src/components/block-mover/button.js | 2 +- .../components/block-pattern-setup/setup-toolbar.js | 4 ++-- .../src/components/block-patterns-paging/index.js | 8 ++++---- .../src/components/link-control/link-preview.js | 2 +- .../src/page-list/convert-to-links-modal.js | 2 +- packages/block-library/src/page-list/edit.js | 2 +- .../src/template-part/edit/title-modal.js | 2 +- .../components/src/autocomplete/autocompleter-ui.tsx | 2 +- .../components/src/button/stories/e2e/index.story.tsx | 2 +- packages/components/src/button/test/index.tsx | 1 + packages/components/src/dropdown-menu/index.tsx | 2 +- packages/components/src/font-size-picker/index.tsx | 2 +- packages/components/src/range-control/index.tsx | 2 +- .../components/src/toolbar/toolbar-button/index.tsx | 2 +- packages/dataviews/src/add-filter.tsx | 2 +- packages/dataviews/src/item-actions.tsx | 2 +- packages/dataviews/src/pagination.tsx | 4 ++-- packages/dataviews/src/reset-filters.tsx | 2 +- packages/dataviews/src/view-list.tsx | 2 +- .../src/components/init-pattern-modal/index.js | 2 +- .../preferences-modal/enable-custom-fields.js | 2 +- .../src/components/global-styles-sidebar/index.js | 4 ++-- .../font-library-modal/font-collection.js | 10 +++++----- .../font-library-modal/installed-fonts.js | 2 +- .../screen-revisions/revisions-buttons.js | 2 +- packages/edit-site/src/components/pagination/index.js | 8 ++++---- packages/edit-site/src/components/save-panel/index.js | 2 +- .../rename-modal.js | 2 +- .../src/hooks/push-changes-to-global-styles/index.js | 2 +- .../src/components/entities-saved-states/index.js | 2 +- packages/editor/src/components/post-actions/actions.js | 8 ++++---- packages/editor/src/components/post-actions/index.js | 2 +- .../editor/src/components/post-preview-button/index.js | 2 +- .../editor/src/components/post-publish-panel/index.js | 2 +- .../editor/src/components/preview-dropdown/index.js | 2 +- .../editor/src/components/save-publish-panels/index.js | 2 +- packages/editor/src/dataviews/actions/delete-post.tsx | 4 ++-- .../src/components/import-form/index.js | 2 +- .../src/components/pattern-overrides-controls.js | 2 +- storybook/stories/playground/with-undo-redo/index.js | 4 ++-- 43 files changed, 62 insertions(+), 61 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 7d1bb161a7c3f1..a3ecf750dbb12e 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -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.)', }, ]; diff --git a/packages/block-directory/src/components/downloadable-block-list-item/index.js b/packages/block-directory/src/components/downloadable-block-list-item/index.js index e3a770925551cb..b1ef34ccdba596 100644 --- a/packages/block-directory/src/components/downloadable-block-list-item/index.js +++ b/packages/block-directory/src/components/downloadable-block-list-item/index.js @@ -96,7 +96,7 @@ function DownloadableBlockListItem( { composite, item, onClick } ) { { getBlockMoverDescription( diff --git a/packages/block-editor/src/components/block-pattern-setup/setup-toolbar.js b/packages/block-editor/src/components/block-pattern-setup/setup-toolbar.js index 91b68456cda71c..df559194e5b78b 100644 --- a/packages/block-editor/src/components/block-pattern-setup/setup-toolbar.js +++ b/packages/block-editor/src/components/block-pattern-setup/setup-toolbar.js @@ -35,14 +35,14 @@ const CarouselNavigation = ( { label={ __( 'Previous pattern' ) } onClick={ handlePrevious } disabled={ activeSlide === 0 } - __experimentalIsFocusable + accessibleWhenDisabled /> @@ -51,7 +51,7 @@ export default function Pagination( { onClick={ () => changePage( currentPage - 1 ) } disabled={ currentPage === 1 } aria-label={ __( 'Previous page' ) } - __experimentalIsFocusable + accessibleWhenDisabled > @@ -74,7 +74,7 @@ export default function Pagination( { onClick={ () => changePage( currentPage + 1 ) } disabled={ currentPage === numPages } aria-label={ __( 'Next page' ) } - __experimentalIsFocusable + accessibleWhenDisabled > @@ -84,7 +84,7 @@ export default function Pagination( { disabled={ currentPage === numPages } aria-label={ __( 'Last page' ) } size="default" - __experimentalIsFocusable + accessibleWhenDisabled > » diff --git a/packages/block-editor/src/components/link-control/link-preview.js b/packages/block-editor/src/components/link-control/link-preview.js index d06c9971c680bf..e5de47f0153a82 100644 --- a/packages/block-editor/src/components/link-control/link-preview.js +++ b/packages/block-editor/src/components/link-control/link-preview.js @@ -166,7 +166,7 @@ export default function LinkPreview( { isEmptyURL || showIconLabels ? '' : ': ' + value.url ) } ref={ ref } - __experimentalIsFocusable + accessibleWhenDisabled disabled={ isEmptyURL } size="compact" /> diff --git a/packages/block-library/src/page-list/convert-to-links-modal.js b/packages/block-library/src/page-list/convert-to-links-modal.js index 12277bee01faf1..209987b1942386 100644 --- a/packages/block-library/src/page-list/convert-to-links-modal.js +++ b/packages/block-library/src/page-list/convert-to-links-modal.js @@ -36,7 +36,7 @@ export function ConvertToLinksModal( { onClick, onClose, disabled } ) { diff --git a/packages/edit-post/src/components/preferences-modal/enable-custom-fields.js b/packages/edit-post/src/components/preferences-modal/enable-custom-fields.js index e655a7300c37ee..94d4f28c632cd6 100644 --- a/packages/edit-post/src/components/preferences-modal/enable-custom-fields.js +++ b/packages/edit-post/src/components/preferences-modal/enable-custom-fields.js @@ -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 ); diff --git a/packages/edit-site/src/components/global-styles-sidebar/index.js b/packages/edit-site/src/components/global-styles-sidebar/index.js index f57cc8c417f410..b314b5d7e75244 100644 --- a/packages/edit-site/src/components/global-styles-sidebar/index.js +++ b/packages/edit-site/src/components/global-styles-sidebar/index.js @@ -152,7 +152,7 @@ export default function GlobalStylesSidebar() { isPressed={ isStyleBookOpened || isRevisionsStyleBookOpened } - __experimentalIsFocusable + accessibleWhenDisabled disabled={ shouldClearCanvasContainerView } onClick={ toggleStyleBook } size="compact" @@ -163,7 +163,7 @@ export default function GlobalStylesSidebar() { label={ __( 'Revisions' ) } icon={ backup } onClick={ toggleRevisions } - __experimentalIsFocusable + accessibleWhenDisabled disabled={ ! hasRevisions } isPressed={ isRevisionsOpened || isRevisionsStyleBookOpened diff --git a/packages/edit-site/src/components/global-styles/font-library-modal/font-collection.js b/packages/edit-site/src/components/global-styles/font-library-modal/font-collection.js index db9e3cb402561b..9cb446b1d16ab0 100644 --- a/packages/edit-site/src/components/global-styles/font-library-modal/font-collection.js +++ b/packages/edit-site/src/components/global-styles/font-library-modal/font-collection.js @@ -438,7 +438,7 @@ function FontCollection( { slug } ) { disabled={ fontsToInstall.length === 0 || isInstalling } - __experimentalIsFocusable + accessibleWhenDisabled > { __( 'Install' ) } @@ -455,7 +455,7 @@ function FontCollection( { slug } ) { size="compact" onClick={ () => setPage( 1 ) } disabled={ page === 1 } - __experimentalIsFocusable + accessibleWhenDisabled > « @@ -464,7 +464,7 @@ function FontCollection( { slug } ) { size="compact" onClick={ () => setPage( page - 1 ) } disabled={ page === 1 } - __experimentalIsFocusable + accessibleWhenDisabled > @@ -514,7 +514,7 @@ function FontCollection( { slug } ) { size="compact" onClick={ () => setPage( page + 1 ) } disabled={ page === totalPages } - __experimentalIsFocusable + accessibleWhenDisabled > @@ -523,7 +523,7 @@ function FontCollection( { slug } ) { size="compact" onClick={ () => setPage( totalPages ) } disabled={ page === totalPages } - __experimentalIsFocusable + accessibleWhenDisabled > » diff --git a/packages/edit-site/src/components/global-styles/font-library-modal/installed-fonts.js b/packages/edit-site/src/components/global-styles/font-library-modal/installed-fonts.js index c644c219348a6e..464540bc2b4ea7 100644 --- a/packages/edit-site/src/components/global-styles/font-library-modal/installed-fonts.js +++ b/packages/edit-site/src/components/global-styles/font-library-modal/installed-fonts.js @@ -329,7 +329,7 @@ function InstalledFonts() { saveFontFamilies( fontFamilies ); } } disabled={ ! fontFamiliesHasChanges } - __experimentalIsFocusable + accessibleWhenDisabled > { __( 'Update' ) } diff --git a/packages/edit-site/src/components/global-styles/screen-revisions/revisions-buttons.js b/packages/edit-site/src/components/global-styles/screen-revisions/revisions-buttons.js index 7f4f9896344b4f..a17e5fde5763a7 100644 --- a/packages/edit-site/src/components/global-styles/screen-revisions/revisions-buttons.js +++ b/packages/edit-site/src/components/global-styles/screen-revisions/revisions-buttons.js @@ -163,7 +163,7 @@ function RevisionsButtons( { > diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-navigation-menu/rename-modal.js b/packages/edit-site/src/components/sidebar-navigation-screen-navigation-menu/rename-modal.js index f704f2354e4391..d1a2df9df6cdc3 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-navigation-menu/rename-modal.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-navigation-menu/rename-modal.js @@ -49,7 +49,7 @@ export default function RenameModal( { menuTitle, onClose, onSave } ) { @@ -234,7 +234,7 @@ const trashPostAction = { } } isBusy={ isBusy } disabled={ isBusy } - __experimentalIsFocusable + accessibleWhenDisabled > { __( 'Trash' ) } @@ -887,7 +887,7 @@ const resetTemplateAction = { variant="tertiary" onClick={ closeModal } disabled={ isBusy } - __experimentalIsFocusable + accessibleWhenDisabled > { __( 'Cancel' ) } @@ -902,7 +902,7 @@ const resetTemplateAction = { } } isBusy={ isBusy } disabled={ isBusy } - __experimentalIsFocusable + accessibleWhenDisabled > { __( 'Reset' ) } diff --git a/packages/editor/src/components/post-actions/index.js b/packages/editor/src/components/post-actions/index.js index 00d256ef67eeef..b2730e760c4270 100644 --- a/packages/editor/src/components/post-actions/index.js +++ b/packages/editor/src/components/post-actions/index.js @@ -59,7 +59,7 @@ export default function PostActions( { onActionPerformed, buttonProps } ) { icon={ moreVertical } label={ __( 'Actions' ) } disabled={ ! actions.length } - __experimentalIsFocusable + accessibleWhenDisabled className="editor-all-actions-button" onClick={ () => setIsActionsMenuOpen( ! isActionsMenuOpen ) diff --git a/packages/editor/src/components/post-preview-button/index.js b/packages/editor/src/components/post-preview-button/index.js index e517ac0e8a0fbc..d57143cd355d80 100644 --- a/packages/editor/src/components/post-preview-button/index.js +++ b/packages/editor/src/components/post-preview-button/index.js @@ -183,7 +183,7 @@ export default function PostPreviewButton( { className={ className || 'editor-post-preview' } href={ href } target={ targetId } - __experimentalIsFocusable + accessibleWhenDisabled disabled={ ! isSaveable } onClick={ openPreviewWindow } role={ role } diff --git a/packages/editor/src/components/post-publish-panel/index.js b/packages/editor/src/components/post-publish-panel/index.js index 009d008c72c962..28567c60780219 100644 --- a/packages/editor/src/components/post-publish-panel/index.js +++ b/packages/editor/src/components/post-publish-panel/index.js @@ -93,7 +93,7 @@ export class PostPublishPanel extends Component {
diff --git a/packages/editor/src/dataviews/actions/delete-post.tsx b/packages/editor/src/dataviews/actions/delete-post.tsx index e5810e32fde69a..36400702dae3f6 100644 --- a/packages/editor/src/dataviews/actions/delete-post.tsx +++ b/packages/editor/src/dataviews/actions/delete-post.tsx @@ -77,7 +77,7 @@ const deletePostAction: Action< Post > = { variant="tertiary" onClick={ closeModal } disabled={ isBusy } - __experimentalIsFocusable + accessibleWhenDisabled > { __( 'Cancel' ) } @@ -94,7 +94,7 @@ const deletePostAction: Action< Post > = { } } isBusy={ isBusy } disabled={ isBusy } - __experimentalIsFocusable + accessibleWhenDisabled > { __( 'Delete' ) } diff --git a/packages/list-reusable-blocks/src/components/import-form/index.js b/packages/list-reusable-blocks/src/components/import-form/index.js index aa2f3133b7a6ef..9c6e8bf57835f1 100644 --- a/packages/list-reusable-blocks/src/components/import-form/index.js +++ b/packages/list-reusable-blocks/src/components/import-form/index.js @@ -86,7 +86,7 @@ function ImportForm( { instanceId, onUpload } ) {