Skip to content

Commit

Permalink
Don't focus on video unless you've just given consent, sort focus sta…
Browse files Browse the repository at this point in the history
…te, fix cookie in safari
  • Loading branch information
helenb committed Mar 27, 2024
1 parent ecb7600 commit 7988473
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 2 additions & 4 deletions tbx/static_src/javascript/components/youtube-embed.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,20 @@ class YouTubeConsentManager {
loadYouTubeEmbed() {
// Hide the video placeholder and show the YouTube embed container
this.youtubeEmbedNode.classList.add('loaded');
this.embedContainer.setAttribute('tabindex', '1');
this.embedContainer.focus();
}

handleconsentClick() {
if (this.dontAskAgainCheckbox.checked) {
this.handleDontAskAgainClick();
}
this.loadYouTubeEmbed();
this.embedContainer.querySelector('button').focus();
}

handleDontAskAgainClick() {
// Set a cookie to remember the user's choice not to ask again
Cookies.set('youtube_consent', 'true', {
expires: 7,
secure: true,
expires: 365,
sameSite: 'Lax',
});

Expand Down
5 changes: 5 additions & 0 deletions tbx/static_src/sass/components/_youtube-embed.scss
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,10 @@
@media (scripting: none) {
display: block;
}

button:focus {
@include focus-style();
outline-offset: -2px;
}
}
}

0 comments on commit 7988473

Please sign in to comment.