Skip to content

Commit bb7670c

Browse files
author
mrleemurray
committed
Refactor StickyHeader to manage inert attribute and aria-hidden for improved accessibility
1 parent 084aff7 commit bb7670c

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

webviews/components/stickyHeader.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,18 @@ export function StickyHeader({ pr, visible }: { pr: PullRequest; visible: boolea
3434
const { text, color, icon } = getStatus(pr.state, !!pr.isDraft, pr.isIssue, pr.stateReason);
3535
const { copyPrLink } = React.useContext(PullRequestContext);
3636

37-
const hiddenProps: Record<string, string> = visible ? {} : { inert: '', 'aria-hidden': 'true' };
37+
const stickyRef = React.useCallback((node: HTMLDivElement | null) => {
38+
if (node) {
39+
if (visible) {
40+
node.removeAttribute('inert');
41+
} else {
42+
node.setAttribute('inert', '');
43+
}
44+
}
45+
}, [visible]);
3846

3947
return (
40-
<div className={`sticky-header${visible ? ' visible' : ''}`} {...hiddenProps}>
48+
<div ref={stickyRef} className={`sticky-header${visible ? ' visible' : ''}`}>
4149
<div className="sticky-header-left">
4250
<div id="sticky-status" className={`status-badge-${color}`}>
4351
<span className="icon">{icon}</span>

0 commit comments

Comments
 (0)