From 39777ea12223ef2ab8f15cb42990676df1c13006 Mon Sep 17 00:00:00 2001 From: Andrea Fercia Date: Tue, 25 Jun 2024 19:12:35 +0200 Subject: [PATCH] Fix lock modal dialog accessibility and semantics (#62795) * Use fieldset and legend instead of labeled group. * Make lock options a nested list. Co-authored-by: afercia Co-authored-by: alexstine Co-authored-by: t-hamano Co-authored-by: Mamaduka --- .../src/components/block-lock/modal.js | 177 ++++++++++-------- .../src/components/block-lock/style.scss | 12 +- 2 files changed, 106 insertions(+), 83 deletions(-) diff --git a/packages/block-editor/src/components/block-lock/modal.js b/packages/block-editor/src/components/block-lock/modal.js index cfafa6c031bbd1..11a03c5aff4dd8 100644 --- a/packages/block-editor/src/components/block-lock/modal.js +++ b/packages/block-editor/src/components/block-lock/modal.js @@ -13,7 +13,6 @@ import { ToggleControl, } from '@wordpress/components'; import { lock as lockIcon, unlock as unlockIcon } from '@wordpress/icons'; -import { useInstanceId } from '@wordpress/compose'; import { useDispatch, useSelect } from '@wordpress/data'; import { getBlockType } from '@wordpress/blocks'; @@ -64,10 +63,6 @@ export default function BlockLockModal( { clientId, onClose } ) { ); const { updateBlockAttributes } = useDispatch( blockEditorStore ); const blockInformation = useBlockDisplayInformation( clientId ); - const instanceId = useInstanceId( - BlockLockModal, - 'block-editor-block-lock-modal__options-title' - ); useEffect( () => { setLock( { @@ -90,11 +85,6 @@ export default function BlockLockModal( { clientId, onClose } ) { overlayClassName="block-editor-block-lock-modal" onRequestClose={ onClose } > -

- { __( - 'Choose specific attributes to restrict or lock all available options.' - ) } -

{ event.preventDefault(); @@ -107,84 +97,107 @@ export default function BlockLockModal( { clientId, onClose } ) { onClose(); } } > -
- { __( 'Lock all' ) } - } - checked={ isAllChecked } - indeterminate={ isMixed } - onChange={ ( newValue ) => - setLock( { - move: newValue, - remove: newValue, - ...( allowsEditLocking - ? { edit: newValue } - : {} ), - } ) - } - /> -
    - { allowsEditLocking && ( -
  • - - setLock( ( prevLock ) => ( { - ...prevLock, - edit, - } ) ) - } - /> - -
  • +
    + + { __( + 'Choose specific attributes to restrict or lock all available options.' ) } -
  • + + { /* + * Disable reason: The `list` ARIA role is redundant but + * Safari+VoiceOver won't announce the list otherwise. + */ + /* eslint-disable jsx-a11y/no-redundant-roles */ } +
      +
    • - setLock( ( prevLock ) => ( { - ...prevLock, - move, - } ) ) + className="block-editor-block-lock-modal__options-all" + label={ __( 'Lock all' ) } + checked={ isAllChecked } + indeterminate={ isMixed } + onChange={ ( newValue ) => + setLock( { + move: newValue, + remove: newValue, + ...( allowsEditLocking + ? { edit: newValue } + : {} ), + } ) } /> - -
    • -
    • - - setLock( ( prevLock ) => ( { - ...prevLock, - remove, - } ) ) - } - /> - +
        + { allowsEditLocking && ( +
      • + + setLock( ( prevLock ) => ( { + ...prevLock, + edit, + } ) ) + } + /> + +
      • + ) } +
      • + + setLock( ( prevLock ) => ( { + ...prevLock, + move, + } ) ) + } + /> + +
      • +
      • + + setLock( ( prevLock ) => ( { + ...prevLock, + remove, + } ) ) + } + /> + +
      • +
    + { /* eslint-enable jsx-a11y/no-redundant-roles */ } { hasTemplateLock && ( ) } -
+