Skip to content

Commit 6cbb939

Browse files
authored
devtools: Display shortcuts for prev/next search result (#20470)
1 parent 99554dc commit 6cbb939

File tree

2 files changed

+13
-24
lines changed

2 files changed

+13
-24
lines changed

packages/react-devtools-shared/src/devtools/views/Button.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ import tooltipStyles from './Tooltip.css';
1616
type Props = {
1717
children: React$Node,
1818
className?: string,
19-
title?: string,
19+
title: React$Node,
2020
...
2121
};
2222

2323
export default function Button({
2424
children,
2525
className = '',
26-
title = '',
26+
title,
2727
...rest
2828
}: Props) {
2929
let button = (

packages/react-devtools-shared/src/devtools/views/Components/SearchInput.js

+11-22
Original file line numberDiff line numberDiff line change
@@ -34,25 +34,6 @@ export default function SearchInput(props: Props) {
3434
[dispatch],
3535
);
3636

37-
const handleKeyDown = useCallback(
38-
event => {
39-
// For convenience, let up/down arrow keys change Tree selection.
40-
switch (event.key) {
41-
case 'ArrowDown':
42-
dispatch({type: 'SELECT_NEXT_ELEMENT_IN_TREE'});
43-
event.preventDefault();
44-
break;
45-
case 'ArrowUp':
46-
dispatch({type: 'SELECT_PREVIOUS_ELEMENT_IN_TREE'});
47-
event.preventDefault();
48-
break;
49-
default:
50-
break;
51-
}
52-
},
53-
[dispatch],
54-
);
55-
5637
const handleInputKeyPress = useCallback(
5738
({key, shiftKey}) => {
5839
if (key === 'Enter') {
@@ -98,7 +79,6 @@ export default function SearchInput(props: Props) {
9879
<input
9980
className={styles.Input}
10081
onChange={handleTextChange}
101-
onKeyDown={handleKeyDown}
10282
onKeyPress={handleInputKeyPress}
10383
placeholder="Search (text or /regex/)"
10484
ref={inputRef}
@@ -115,14 +95,23 @@ export default function SearchInput(props: Props) {
11595
className={styles.IconButton}
11696
disabled={!searchText}
11797
onClick={() => dispatch({type: 'GO_TO_PREVIOUS_SEARCH_RESULT'})}
118-
title="Scroll to previous search result">
98+
title={
99+
<React.Fragment>
100+
Scroll to previous search result (<kbd>Shift</kbd> +{' '}
101+
<kbd>Enter</kbd>)
102+
</React.Fragment>
103+
}>
119104
<ButtonIcon type="up" />
120105
</Button>
121106
<Button
122107
className={styles.IconButton}
123108
disabled={!searchText}
124109
onClick={() => dispatch({type: 'GO_TO_NEXT_SEARCH_RESULT'})}
125-
title="Scroll to next search result">
110+
title={
111+
<React.Fragment>
112+
Scroll to next search result (<kbd>Enter</kbd>)
113+
</React.Fragment>
114+
}>
126115
<ButtonIcon type="down" />
127116
</Button>
128117
<Button

0 commit comments

Comments
 (0)