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.
Built from https://develop.svn.wordpress.org/trunk@58450


git-svn-id: http://core.svn.wordpress.org/trunk@57899 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information
joedolson committed Jun 20, 2024
1 parent 026c9a8 commit 95971e1
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion 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
2 changes: 2 additions & 0 deletions wp-includes/js/wplink.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
Loading

0 comments on commit 95971e1

Please sign in to comment.