Skip to content

Commit 7870bf2

Browse files
committed
fix: on focus hidden sentinel
Signed-off-by: Adam Setch <[email protected]>
1 parent 8fdc612 commit 7870bf2

File tree

2 files changed

+42
-16
lines changed

2 files changed

+42
-16
lines changed

src/renderer/components/layout/AppLayout.tsx

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,33 @@ import type { FC, ReactNode } from 'react';
22

33
import { Sidebar } from '../Sidebar';
44

5-
interface IAppLayout {
6-
children: ReactNode;
7-
}
5+
type AppLayoutProps = { children: ReactNode };
86

97
/**
108
* AppLayout is the main container for the application.
119
* It handles the basic layout with sidebar and content area.
1210
*/
13-
export const AppLayout: FC<IAppLayout> = ({ children }) => {
11+
export const AppLayout: FC<AppLayoutProps> = ({ children }) => {
12+
const setFocusRef = (el: HTMLButtonElement | null) => {
13+
if (el) {
14+
el.focus();
15+
}
16+
};
17+
1418
return (
1519
<div className="flex flex-col min-h-screen bg-gitify-background">
16-
{/* Content first in DOM so initial focus won't land on sidebar buttons */}
17-
<div className="flex-1 pl-sidebar">{children}</div>
20+
{/* Hidden focus sentinel; grabs initial focus via callback ref */}
21+
<button
22+
aria-label="initial focus"
23+
className="sr-only"
24+
data-testid="initial-focus-sentinel"
25+
ref={setFocusRef}
26+
type="button"
27+
/>
1828

1929
<Sidebar />
30+
31+
<div className="flex-1 pl-sidebar">{children}</div>
2032
</div>
2133
);
2234
};

src/renderer/components/layout/__snapshots__/AppLayout.test.tsx.snap

Lines changed: 24 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)