mirror of
https://github.com/argoproj/argo-cd
synced 2026-05-23 17:28:44 +00:00
feat: Add a keyboard shortcut to move focus to search (#4796)
Fixes: #4700 Signed-off-by: Chetan Banavikalmutt <chetanrns1997@gmail.com>
This commit is contained in:
parent
6e1649b1e2
commit
6095fc564f
1 changed files with 13 additions and 0 deletions
|
|
@ -165,6 +165,19 @@ export const ApplicationsList = (props: RouteComponentProps<{}>) => {
|
|||
const [isAppCreatePending, setAppCreatePending] = React.useState(false);
|
||||
const searchBar = React.useRef<HTMLDivElement>(null);
|
||||
|
||||
React.useEffect(() => {
|
||||
const handleKeyPress = (e: KeyboardEvent) => {
|
||||
if (e.keyCode === 47 && searchBar.current && !appInput) {
|
||||
searchBar.current.querySelector('input').focus();
|
||||
e.preventDefault();
|
||||
}
|
||||
};
|
||||
document.addEventListener('keypress', handleKeyPress);
|
||||
return () => {
|
||||
document.removeEventListener('keypress', handleKeyPress);
|
||||
};
|
||||
});
|
||||
|
||||
const loaderRef = React.useRef<DataLoader>();
|
||||
function refreshApp(appName: string) {
|
||||
// app refreshing might be done too quickly so that UI might miss it due to event batching
|
||||
|
|
|
|||
Loading…
Reference in a new issue