Skip to content

Commit

Permalink
Merge pull request #371 from bigcapitalhq/big-129-universal-search-sh…
Browse files Browse the repository at this point in the history
…ould-auto-focus-when-it-opens

fix: Universal search should auto-focus when it opens
  • Loading branch information
abouolia authored Feb 25, 2024
2 parents 2cf75e0 + 0aea339 commit 00e6c14
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 8 deletions.
5 changes: 5 additions & 0 deletions packages/server/src/data/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ export default {
type: 'number',
},
},
inventory: {
cost_compute_running: {
type: 'boolean',
},
},
accounts: {
account_code_required: {
type: 'boolean',
Expand Down
32 changes: 26 additions & 6 deletions packages/webapp/src/components/Dashboard/GlobalHotkeys.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -24,7 +28,7 @@ function GlobalHotkeys({
.toString();

const handleSidebarToggleBtn = () => {
toggleSidebarExpend();
toggleSidebarExpand();
};
useHotkeys(
globalHotkeys,
Expand All @@ -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);
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ function UniversalSearchBar({ isOpen, onSearchTypeChange, ...listProps }) {
onSearchTypeChange={onSearchTypeChange}
/>
}
autoFocus={true}
/>
{listProps.itemList}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ import { compose } from '@/utils';
import withUniversalSearchActions from './withUniversalSearchActions';
import withUniversalSearch from './withUniversalSearch';

import { useGetUniversalSearchTypeOptions } from './utils';
import DashboardUniversalSearchItemActions from './DashboardUniversalSearchItemActions';
import { DashboardUniversalSearchItem } from './components';

import DashboardUniversalSearchHotkeys from './DashboardUniversalSearchHotkeys';
import { useGetUniversalSearchTypeOptions } from './utils';

/**
* Dashboard universal search.
Expand Down

0 comments on commit 00e6c14

Please sign in to comment.