Skip to content

Commit

Permalink
fix(a11y): Fix focus loop on tab in Add to album modal
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Ng <[email protected]>

[skip ci]
  • Loading branch information
Pytal authored and backportbot[bot] committed Jan 30, 2024
1 parent d1f699d commit 5a97009
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/components/File.vue
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,9 @@ export default {
box-sizing: border-box;

// Selection border.
&.selected, &:focus-within {
&.selected,
&:focus-within,
&:has(:focus) {
&::after {
position: absolute;
top: 0;
Expand All @@ -246,6 +248,9 @@ export default {
outline-offset: -4px;
pointer-events: none;
}
.selection-checkbox {
opacity: 1;
}
}

.file {
Expand Down
12 changes: 11 additions & 1 deletion src/components/FilesPicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
:base-height="100"
:section-header-height="50"
:scroll-to-section="targetMonth"
@need-content="getFiles">
@need-content="getFiles"
@focusout.native="onFocusOut">
<template slot-scope="{file, height, isHeader, distance}">
<h3 v-if="isHeader"
:id="`photos-picker-section-header-${file.id}`"
Expand Down Expand Up @@ -183,6 +184,15 @@ export default {
},

methods: {
/**
* @param {FocusEvent} event The focus event
*/
onFocusOut(event) {
if (event.relatedTarget === null) { // Focus escaping to body
event.target.focus({ preventScroll: true })
}
},

getFiles() {
this.fetchFiles('', {}, this.blacklistIds)
},
Expand Down

0 comments on commit 5a97009

Please sign in to comment.