fix: Universal search should auto-focus when it opens

This commit is contained in:
Ahmed Bouhuolia
2024-02-26 01:16:55 +02:00
parent 2cf75e0136
commit 0aea339c1c
4 changed files with 33 additions and 8 deletions

View File

@@ -5,12 +5,16 @@ import { useHistory } from 'react-router-dom';
import { getDashboardRoutes } from '@/routes/dashboard';
import withDashboardActions from '@/containers/Dashboard/withDashboardActions';
import withDialogActions from '@/containers/Dialog/withDialogActions';
import withUniversalSearchActions from '@/containers/UniversalSearch/withUniversalSearchActions';
import { compose } from '@/utils';
function GlobalHotkeys({
// #withDashboardActions
toggleSidebarExpend,
toggleSidebarExpand,
// withUniversalSearchActions
openGlobalSearch,
// #withDialogActions
openDialog,
@@ -24,7 +28,7 @@ function GlobalHotkeys({
.toString();
const handleSidebarToggleBtn = () => {
toggleSidebarExpend();
toggleSidebarExpand();
};
useHotkeys(
globalHotkeys,
@@ -37,10 +41,26 @@ function GlobalHotkeys({
},
[history],
);
useHotkeys('ctrl+/', (event, handle) => handleSidebarToggleBtn());
useHotkeys('shift+d', (event, handle) => openDialog('money-in', {}));
useHotkeys('shift+q', (event, handle) => openDialog('money-out', {}));
useHotkeys('ctrl+/', () => {
handleSidebarToggleBtn();
});
useHotkeys('shift+d', () => {
openDialog('money-in', {});
});
useHotkeys('shift+q', () => {
openDialog('money-out', {});
});
useHotkeys('/', () => {
setTimeout(() => {
openGlobalSearch();
}, 0);
});
return <div></div>;
}
export default compose(withDashboardActions, withDialogActions)(GlobalHotkeys);
export default compose(
withDashboardActions,
withDialogActions,
withUniversalSearchActions,
)(GlobalHotkeys);

View File

@@ -152,6 +152,7 @@ function UniversalSearchBar({ isOpen, onSearchTypeChange, ...listProps }) {
onSearchTypeChange={onSearchTypeChange}
/>
}
autoFocus={true}
/>
{listProps.itemList}
</div>