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

Improve accessibility of the Warning component in the block editor #67433

Merged
merged 6 commits into from
Dec 19, 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
14 changes: 13 additions & 1 deletion packages/block-editor/src/components/warning/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,23 @@ import clsx from 'clsx';
import { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { moreVertical } from '@wordpress/icons';
import { useEffect, useRef } from '@wordpress/element';

function Warning( { className, actions, children, secondaryActions } ) {
const alertRef = useRef();

useEffect( () => {
alertRef.current?.focus();
}, [] );
sarthaknagoshe2002 marked this conversation as resolved.
Show resolved Hide resolved

return (
<div style={ { display: 'contents', all: 'initial' } }>
<div className={ clsx( className, 'block-editor-warning' ) }>
<div
className={ clsx( className, 'block-editor-warning' ) }
tabIndex="0"
ref={ alertRef }
role="alert"
>
<div className="block-editor-warning__contents">
<p className="block-editor-warning__message">
{ children }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ exports[`Warning should match snapshot 1`] = `
>
<div
class="block-editor-warning"
role="alert"
tabindex="0"
>
<div
class="block-editor-warning__contents"
Expand Down
Loading