Skip to content

Commit

Permalink
devtools: Display shortcuts for prev/next search result (facebook#20470)
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon authored and koto committed Jun 15, 2021
1 parent d2989a8 commit 5c6067c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 24 deletions.
4 changes: 2 additions & 2 deletions packages/react-devtools-shared/src/devtools/views/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ import tooltipStyles from './Tooltip.css';
type Props = {
children: React$Node,
className?: string,
title?: string,
title: React$Node,
...
};

export default function Button({
children,
className = '',
title = '',
title,
...rest
}: Props) {
let button = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,6 @@ export default function SearchInput(props: Props) {
[dispatch],
);

const handleKeyDown = useCallback(
event => {
// For convenience, let up/down arrow keys change Tree selection.
switch (event.key) {
case 'ArrowDown':
dispatch({type: 'SELECT_NEXT_ELEMENT_IN_TREE'});
event.preventDefault();
break;
case 'ArrowUp':
dispatch({type: 'SELECT_PREVIOUS_ELEMENT_IN_TREE'});
event.preventDefault();
break;
default:
break;
}
},
[dispatch],
);

const handleInputKeyPress = useCallback(
({key, shiftKey}) => {
if (key === 'Enter') {
Expand Down Expand Up @@ -98,7 +79,6 @@ export default function SearchInput(props: Props) {
<input
className={styles.Input}
onChange={handleTextChange}
onKeyDown={handleKeyDown}
onKeyPress={handleInputKeyPress}
placeholder="Search (text or /regex/)"
ref={inputRef}
Expand All @@ -115,14 +95,23 @@ export default function SearchInput(props: Props) {
className={styles.IconButton}
disabled={!searchText}
onClick={() => dispatch({type: 'GO_TO_PREVIOUS_SEARCH_RESULT'})}
title="Scroll to previous search result">
title={
<React.Fragment>
Scroll to previous search result (<kbd>Shift</kbd> +{' '}
<kbd>Enter</kbd>)
</React.Fragment>
}>
<ButtonIcon type="up" />
</Button>
<Button
className={styles.IconButton}
disabled={!searchText}
onClick={() => dispatch({type: 'GO_TO_NEXT_SEARCH_RESULT'})}
title="Scroll to next search result">
title={
<React.Fragment>
Scroll to next search result (<kbd>Enter</kbd>)
</React.Fragment>
}>
<ButtonIcon type="down" />
</Button>
<Button
Expand Down

0 comments on commit 5c6067c

Please sign in to comment.