Fix search fallback action (#10256)
The command menu search bar was reset after clicking on the `Search records` fallback action, but it shouldn't. This PR: - Introduces a new type of action: `Fallback` actions - Reset the search bar only if the action key differs from 'record-search-fallback'
This commit is contained in:
@ -29,4 +29,17 @@ export const RECORD_AGNOSTIC_ACTIONS_CONFIG: Record<
|
||||
useAction: useSearchRecordsRecordAgnosticAction,
|
||||
hotKeys: ['/'],
|
||||
},
|
||||
searchRecordsFallback: {
|
||||
type: ActionMenuEntryType.Fallback,
|
||||
scope: ActionMenuEntryScope.Global,
|
||||
key: RecordAgnosticActionsKey.SEARCH_RECORDS_FALLBACK,
|
||||
label: msg`Search records`,
|
||||
shortLabel: msg`Search`,
|
||||
position: 1,
|
||||
isPinned: false,
|
||||
Icon: IconSearch,
|
||||
availableOn: [ActionViewType.GLOBAL],
|
||||
useAction: useSearchRecordsRecordAgnosticAction,
|
||||
hotKeys: ['/'],
|
||||
},
|
||||
};
|
||||
|
||||
@ -1,17 +1,11 @@
|
||||
import { useCommandMenu } from '@/command-menu/hooks/useCommandMenu';
|
||||
import { commandMenuSearchState } from '@/command-menu/states/commandMenuSearchState';
|
||||
import { CommandMenuPages } from '@/command-menu/types/CommandMenuPages';
|
||||
import { useSetRecoilState } from 'recoil';
|
||||
import { IconSearch } from 'twenty-ui';
|
||||
|
||||
export const useSearchRecordsRecordAgnosticAction = () => {
|
||||
const { navigateCommandMenu } = useCommandMenu();
|
||||
|
||||
const setCommandMenuSearch = useSetRecoilState(commandMenuSearchState);
|
||||
|
||||
const onClick = () => {
|
||||
setCommandMenuSearch('');
|
||||
|
||||
navigateCommandMenu({
|
||||
page: CommandMenuPages.SearchRecords,
|
||||
pageTitle: 'Search',
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
export enum RecordAgnosticActionsKey {
|
||||
SEARCH_RECORDS = 'search-records',
|
||||
SEARCH_RECORDS_FALLBACK = 'search-records-fallback',
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ import { IconComponent, MenuItemAccent } from 'twenty-ui';
|
||||
export enum ActionMenuEntryType {
|
||||
Standard = 'Standard',
|
||||
WorkflowRun = 'WorkflowRun',
|
||||
Fallback = 'Fallback',
|
||||
}
|
||||
|
||||
export enum ActionMenuEntryScope {
|
||||
|
||||
Reference in New Issue
Block a user