Skip to content

Commit cd0e615

Browse files
authored
fix: on focus hidden sentinel (#2383)
* fix: on focus hidden sentinel Signed-off-by: Adam Setch <adam.setch@outlook.com> * fix: on focus hidden sentinel Signed-off-by: Adam Setch <adam.setch@outlook.com> --------- Signed-off-by: Adam Setch <adam.setch@outlook.com>
1 parent 4566416 commit cd0e615

File tree

5 files changed

+53
-25
lines changed

5 files changed

+53
-25
lines changed

src/renderer/components/Sidebar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export const Sidebar: FC = () => {
6767

6868
return (
6969
<Stack
70-
className="fixed left-sidebar -ml-sidebar w-sidebar h-full bg-gitify-sidebar [&_svg]:text-white"
70+
className="fixed w-sidebar h-full bg-gitify-sidebar [&_svg]:text-white"
7171
direction="vertical"
7272
justify="space-between"
7373
>

src/renderer/components/__snapshots__/Sidebar.test.tsx.snap

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

src/renderer/components/layout/AppLayout.tsx

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

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

5-
interface IAppLayout {
5+
interface AppLayoutProps {
66
children: ReactNode;
77
}
88

99
/**
1010
* AppLayout is the main container for the application.
1111
* It handles the basic layout with sidebar and content area.
1212
*/
13-
export const AppLayout: FC<IAppLayout> = ({ children }) => {
13+
export const AppLayout: FC<AppLayoutProps> = ({ children }) => {
14+
const setFocusRef = (el: HTMLButtonElement | null) => {
15+
if (el) {
16+
el.focus();
17+
}
18+
};
19+
1420
return (
15-
<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>
21+
<div className="flex min-h-screen bg-gitify-background">
22+
{/* Hidden focus sentinel; grabs initial focus via callback ref */}
23+
<button
24+
aria-label="initial focus"
25+
className="sr-only"
26+
data-testid="initial-focus-sentinel"
27+
ref={setFocusRef}
28+
type="button"
29+
/>
1830

1931
<Sidebar />
32+
33+
<div className="flex-1 pl-sidebar">{children}</div>
2034
</div>
2135
);
2236
};

src/renderer/components/layout/Page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { FC, ReactNode } from 'react';
22

33
interface IPage {
44
children: ReactNode;
5-
testId?: string;
5+
testId: string;
66
}
77

88
/**

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

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

0 commit comments

Comments
 (0)