Skip to content

Commit

Permalink
Auth VoiceOver (#231)
Browse files Browse the repository at this point in the history
* Auth dropdown WCAG adjustments
---------

Co-authored-by: Abrasimov Yaroslav <[email protected]>
  • Loading branch information
KostiantynFandeliuk and Ferri0 authored Dec 5, 2024
1 parent 09c3741 commit 32af5fc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion blocks/commerce-order-returns/commerce-order-returns.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ export default async function decorate(block) {

return `${returnDetailsPath}?orderRef=${encodedOrderRef}&returnRef=${returnNumber}`;
},
routeProductDetails: (productData) => (productData ? `/products/${productData.product.urlKey}/${productData.product.sku}` : '#'),
routeProductDetails: (productData) => (productData?.product ? `/products/${productData.product.urlKey}/${productData.product.sku}` : '#'),
})(block);
}
2 changes: 1 addition & 1 deletion blocks/commerce-orders-list/commerce-orders-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default async function decorate(block) {
routeOrdersList: () => CUSTOMER_ORDERS_PATH,
routeOrderDetails: (orderNumber) => `${CUSTOMER_ORDER_DETAILS_PATH}?orderRef=${orderNumber}`,
routeReturnDetails: ({ orderNumber, returnNumber }) => `${CUSTOMER_RETURN_DETAILS_PATH}?orderRef=${orderNumber}&returnRef=${returnNumber}`,
routeOrderProduct: (productData) => (productData ? `/products/${productData.product.urlKey}/${productData.product.sku}` : '#'),
routeOrderProduct: (productData) => (productData?.product ? `/products/${productData.product.urlKey}/${productData.product.sku}` : '#'),
})(block);
}
}
2 changes: 1 addition & 1 deletion blocks/commerce-returns-list/commerce-returns-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default async function decorate(block) {
routeReturnDetails: ({ orderNumber, returnNumber }) => `${CUSTOMER_RETURN_DETAILS_PATH}?orderRef=${orderNumber}&returnRef=${returnNumber}`,
routeOrderDetails: ({ orderNumber }) => `${CUSTOMER_ORDER_DETAILS_PATH}?orderRef=${orderNumber}`,
routeReturnsList: () => CUSTOMER_RETURNS_PATH,
routeProductDetails: (productData) => (productData ? `/products/${productData.product.urlKey}/${productData.product.sku}` : '#'),
routeProductDetails: (productData) => (productData?.product ? `/products/${productData.product.urlKey}/${productData.product.sku}` : '#'),
})(block);
}
}
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

0 comments on commit 32af5fc

Please sign in to comment.