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:
Raphaël Bosi
2025-02-17 15:24:42 +01:00
committed by GitHub
parent e8a55fd4dc
commit e6a484bb58
7 changed files with 38 additions and 26 deletions

View File

@ -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: ['/'],
},
};

View File

@ -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',

View File

@ -1,3 +1,4 @@
export enum RecordAgnosticActionsKey {
SEARCH_RECORDS = 'search-records',
SEARCH_RECORDS_FALLBACK = 'search-records-fallback',
}

View File

@ -7,6 +7,7 @@ import { IconComponent, MenuItemAccent } from 'twenty-ui';
export enum ActionMenuEntryType {
Standard = 'Standard',
WorkflowRun = 'WorkflowRun',
Fallback = 'Fallback',
}
export enum ActionMenuEntryScope {