Skip to content

Commit 2acf9cd

Browse files
feat(stories): Add / search hotkey (#68995)
1 parent c818e44 commit 2acf9cd

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

static/app/views/stories/index.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import {useState} from 'react';
1+
import {useRef, useState} from 'react';
22
import type {RouteComponentProps} from 'react-router';
33
import styled from '@emotion/styled';
44

55
import Input from 'sentry/components/input';
66
import {space} from 'sentry/styles/space';
7+
import {useHotkeys} from 'sentry/utils/useHotkeys';
78
import OrganizationContainer from 'sentry/views/organizationContainer';
89
import EmptyStory from 'sentry/views/stories/emptyStory';
910
import ErrorStory from 'sentry/views/stories/errorStory';
@@ -19,6 +20,9 @@ type Props = RouteComponentProps<{}, {}, any, StoriesQuery>;
1920
export default function Stories({location}: Props) {
2021
const story = useStoriesLoader({filename: location.query.name});
2122
const [searchTerm, setSearchTerm] = useState('');
23+
const searchInput = useRef<HTMLInputElement>(null);
24+
25+
useHotkeys([{match: '/', callback: () => searchInput.current?.focus()}], []);
2226

2327
return (
2428
<OrganizationContainer>
@@ -27,6 +31,7 @@ export default function Stories({location}: Props) {
2731

2832
<Sidebar style={{gridArea: 'aside'}}>
2933
<Input
34+
ref={searchInput}
3035
placeholder="Search files by name"
3136
onChange={e => setSearchTerm(e.target.value.toLowerCase())}
3237
/>

0 commit comments

Comments
 (0)