Skip to content

Commit

Permalink
Editor: A11y: Set ARIA attributes for Classic Editor link inserter.
Browse files Browse the repository at this point in the history
Set `aria-modal` and `aria-hidden` attributes when the Classic Editor link inserter modal is active, so that content behind the modal will be properly treated as inert when interacting with the modal.

Props lyonmuller, jwgoedert, sabernhardt, alexstine, afercia, rajinsharwar, rcreators, audrasjb, hmbashar, joedolson.
Fixes #60799.

git-svn-id: https://develop.svn.wordpress.org/trunk@58450 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
joedolson committed Jun 20, 2024
1 parent a2549c3 commit 33f4435
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/js/_enqueues/lib/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
var ed,
$body = $( document.body );

$( '#wpwrap' ).attr( 'aria-hidden', 'true' );
$body.addClass( 'modal-open' );
wpLink.modalOpen = true;

Expand Down Expand Up @@ -281,6 +282,7 @@

close: function( reset ) {
$( document.body ).removeClass( 'modal-open' );
$( '#wpwrap' ).removeAttr( 'aria-hidden' );
wpLink.modalOpen = false;

if ( reset !== 'noReset' ) {
Expand Down
2 changes: 1 addition & 1 deletion src/wp-includes/class-wp-editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -1875,7 +1875,7 @@ public static function wp_link_dialog() {
// `display: none` is required here, see #WP27605.
?>
<div id="wp-link-backdrop" style="display: none"></div>
<div id="wp-link-wrap" class="wp-core-ui" style="display: none" role="dialog" aria-labelledby="link-modal-title">
<div id="wp-link-wrap" class="wp-core-ui" style="display: none" role="dialog" aria-modal="true" aria-labelledby="link-modal-title">
<form id="wp-link" tabindex="-1">
<?php wp_nonce_field( 'internal-linking', '_ajax_linking_nonce', false ); ?>
<h1 id="link-modal-title"><?php _e( 'Insert/edit link' ); ?></h1>
Expand Down

0 comments on commit 33f4435

Please sign in to comment.