Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auth VoiceOver #231

Merged
merged 14 commits into from
Dec 5, 2024
15 changes: 12 additions & 3 deletions blocks/header/renderAuthDropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function renderSignIn(element) {
export function renderAuthDropdown(navTools) {
const dropdownElement = document.createRange().createContextualFragment(`
<div class="dropdown-wrapper nav-tools-wrapper">
<button type="button" class="nav-dropdown-button"></button>
<button type="button" class="nav-dropdown-button" aria-haspopup="dialog" aria-expanded="false" aria-controls="login-modal"></button>
<div class="nav-auth-menu-panel nav-tools-panel">
<div id="auth-dropin-container"></div>
<ul class="authenticated-user-menu">
Expand All @@ -43,17 +43,26 @@ export function renderAuthDropdown(navTools) {
navTools.append(dropdownElement);

const authDropDownPanel = navTools.querySelector('.nav-auth-menu-panel');
const authDropDownMenuList = navTools.querySelector('.authenticated-user-menu');
const authDropDownMenuList = navTools.querySelector(
'.authenticated-user-menu',
);
const authDropinContainer = navTools.querySelector('#auth-dropin-container');
const loginButton = navTools.querySelector('.nav-dropdown-button');
const logoutButtonElement = navTools.querySelector('.authenticated-user-menu > li > button');
const logoutButtonElement = navTools.querySelector(
'.authenticated-user-menu > li > button',
);

authDropDownPanel.addEventListener('click', (e) => e.stopPropagation());

async function toggleDropDownAuthMenu(state) {
const show = state ?? !authDropDownPanel.classList.contains('nav-tools-panel--show');

authDropDownPanel.classList.toggle('nav-tools-panel--show', show);
authDropDownPanel.setAttribute('role', 'dialog');
authDropDownPanel.setAttribute('aria-hidden', 'false');
authDropDownPanel.setAttribute('aria-labelledby', 'modal-title');
authDropDownPanel.setAttribute('aria-describedby', 'modal-description');
authDropDownPanel.focus();
}

loginButton.addEventListener('click', () => toggleDropDownAuthMenu());
Expand Down
Loading