Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions src/components/formFields/select/select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,51 @@ const setAttributes = (): void => {
});
};

const updateIndicatorAttributes = (indicator: HTMLElement, isInteractive: boolean) => {
if (isInteractive) {
indicator.setAttribute("role", "button");
indicator.setAttribute("tabindex", "0");
indicator.setAttribute("aria-label", "Clear selection");
} else {
indicator.setAttribute("role", "presentation");
indicator.removeAttribute("tabindex");
indicator.removeAttribute("aria-label");
}
};

const setAriaLabelsForIndicators = () => {
document.querySelectorAll('[class*="control"]').forEach((control) => {
const indicatorsParent = control.querySelector('[class*="indicatorSeparator"]')?.parentElement;
if (!indicatorsParent) return;

const indicators = indicatorsParent.querySelectorAll('[class*="indicatorContainer"]');
const hasSelection = indicators.length === 2;

indicators.forEach((indicator, index) => {
const isClearButton = hasSelection && index === 0;
updateIndicatorAttributes(indicator as HTMLElement, isClearButton);
});
});
};

// Initial static setup
setRoleToPresentation('[id*="live-region"]', "presentation");
setRoleToPresentation('[class*="indicatorSeparator"]', "separator");
setRoleToPresentation('[class*="a11yText"]', "presentation");

// Dynamic setup after render
setTimeout(() => {
setAriaLabelsForIndicators();

const observer = new MutationObserver(setAriaLabelsForIndicators);

document.querySelectorAll('[class*="control"]').forEach((control) => {
const indicatorsParent = control.querySelector('[class*="indicatorSeparator"]')?.parentElement;
if (indicatorsParent) {
observer.observe(indicatorsParent, { childList: true, subtree: false });
}
});
}, 100);
};

export const SelectMultiple = ({
Expand Down
5 changes: 4 additions & 1 deletion src/components/logo/Logo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@ interface LogoProps {
variant?: "header" | "footer" | "navbar";
onClick?: () => any;
layoutClassName?: string;
altText?: string;
}

export const Logo: React.FC<LogoProps> = ({ onClick, layoutClassName, variant = "header" }) => {
export const Logo: React.FC<LogoProps> = ({ onClick, layoutClassName, variant = "header", altText }) => {
return (
<div
className={clsx(styles.container, styles[variant], [
onClick && styles.clickable,
layoutClassName && layoutClassName,
])}
role="img"
aria-label={altText || "Logo"}
{...{ onClick }}
/>
);
Expand Down