Skip to content

Commit

Permalink
Move focus to the dialog when opening the lightbox.
Browse files Browse the repository at this point in the history
  • Loading branch information
afercia committed Oct 19, 2023
1 parent 40b7b57 commit ab653a4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/block-library/src/image/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ class="lightbox-trigger"
data-wp-on--touchmove="actions.core.image.handleTouchMove"
data-wp-on--touchend="actions.core.image.handleTouchEnd"
data-wp-on--click="actions.core.image.hideLightbox"
tabindex="-1"
>
<button type="button" aria-label="$close_button_label" style="fill: $close_button_color" class="close-button" data-wp-on--click="actions.core.image.hideLightbox">
$close_button_icon
Expand Down
3 changes: 2 additions & 1 deletion packages/block-library/src/image/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,8 @@ store(
focusableElements.length - 1
];

ref.querySelector( '.close-button' ).focus();
// Move focus to the dialog when opening it.
ref.focus();
}
},
setButtonStyles: ( { context, ref } ) => {
Expand Down

0 comments on commit ab653a4

Please sign in to comment.