Skip to content

Commit 292cdb7

Browse files
authored
Keyboard focus order is not proper on "Description" and "Create github pull request" screen: A11y_Visual Studio Code Web Extensions_Github Pull request_Description_Keyboard (#6578)
Fixes #6451
1 parent 9dfe878 commit 292cdb7

1 file changed

Lines changed: 43 additions & 11 deletions

File tree

webviews/editorWebview/overview.tsx

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,53 @@ import { StatusChecksSection } from '../components/merge';
1212
import Sidebar from '../components/sidebar';
1313
import { Timeline } from '../components/timeline';
1414

15-
export const Overview = (pr: PullRequest) => (
16-
<>
15+
const useMediaQuery = (query: string) => {
16+
const [matches, setMatches] = React.useState(window.matchMedia(query).matches);
17+
18+
React.useEffect(() => {
19+
const mediaQueryList = window.matchMedia(query);
20+
const documentChangeHandler = () => setMatches(mediaQueryList.matches);
21+
22+
mediaQueryList.addEventListener('change', documentChangeHandler);
23+
24+
return () => {
25+
mediaQueryList.removeEventListener('change', documentChangeHandler);
26+
};
27+
}, [query]);
28+
29+
return matches;
30+
};
31+
32+
export const Overview = (pr: PullRequest) => {
33+
const isSingleColumnLayout = useMediaQuery('(max-width: 925px)');
34+
35+
return <>
1736
<div id="title" className="title">
1837
<div className="details">
1938
<Header {...pr} />
2039
</div>
2140
</div>
22-
<Sidebar {...pr} />
23-
<div id="main">
24-
<div id="description">
25-
<CommentView isPRDescription comment={pr} />
26-
</div>
27-
<Timeline events={pr.events} />
28-
<StatusChecksSection pr={pr} isSimple={false} />
29-
<AddComment {...pr} />
41+
{isSingleColumnLayout ?
42+
<>
43+
<Sidebar {...pr} />
44+
<Main {...pr} />
45+
</>
46+
:
47+
<>
48+
<Main {...pr} />
49+
<Sidebar {...pr} />
50+
</>
51+
}
52+
</>;
53+
};
54+
55+
const Main = (pr: PullRequest) => (
56+
<div id="main">
57+
<div id="description">
58+
<CommentView isPRDescription comment={pr} />
3059
</div>
31-
</>
60+
<Timeline events={pr.events} />
61+
<StatusChecksSection pr={pr} isSimple={false} />
62+
<AddComment {...pr} />
63+
</div>
3264
);

0 commit comments

Comments
 (0)