Fix command menu context chip display on show page (#10267)

## New Company
### Before:
<img width="500" alt="Capture d’écran 2025-02-17 à 16 47 54"
src="https://github.com/user-attachments/assets/4573450d-14b1-41f0-9b86-24003f489fde"
/>

### After:
<img width="500" alt="Capture d’écran 2025-02-17 à 16 46 24"
src="https://github.com/user-attachments/assets/6622bd75-900a-451b-ac21-c98bddeee32d"
/>


## Task
### Before:
<img width="500" alt="Capture d’écran 2025-02-17 à 16 47 35"
src="https://github.com/user-attachments/assets/04b77faa-b628-4839-ab94-95c8570c1818"
/>

### After:
<img width="501" alt="Capture d’écran 2025-02-17 à 16 47 03"
src="https://github.com/user-attachments/assets/1577dea6-7541-497e-af6e-3a4559f1a913"
/>
This commit is contained in:
Raphaël Bosi
2025-02-18 09:52:25 +01:00
committed by GitHub
parent 905cfedaf0
commit 270744eca6
34 changed files with 96 additions and 69 deletions

View File

@ -3,6 +3,7 @@ import { CommandMenuContextRecordChipAvatars } from '@/command-menu/components/C
import { getSelectedRecordsContextText } from '@/command-menu/utils/getRecordContextText';
import { useFindManyRecordsSelectedInContextStore } from '@/context-store/hooks/useFindManyRecordsSelectedInContextStore';
import { useObjectMetadataItemById } from '@/object-metadata/hooks/useObjectMetadataItemById';
import { isDefined } from 'twenty-shared';
import { CommandMenuContextChipProps } from './CommandMenuContextChip';
export const CommandMenuContextChipGroupsWithRecordSelection = ({
@ -21,7 +22,7 @@ export const CommandMenuContextChipGroupsWithRecordSelection = ({
limit: 3,
});
if (loading || !totalCount) {
if (loading) {
return null;
}
@ -33,21 +34,25 @@ export const CommandMenuContextChipGroupsWithRecordSelection = ({
/>
));
const selectedRecordsContextText = getSelectedRecordsContextText(
objectMetadataItem,
records,
totalCount,
);
const recordSelectionContextChip = totalCount
? {
text: getSelectedRecordsContextText(
objectMetadataItem,
records,
totalCount,
),
Icons: Avatars,
}
: undefined;
const contextChipsWithRecordSelection = [
recordSelectionContextChip,
...contextChips,
].filter(isDefined);
return (
<CommandMenuContextChipGroups
contextChips={[
{
text: selectedRecordsContextText,
Icons: Avatars,
},
...contextChips,
]}
contextChips={contextChipsWithRecordSelection}
/>
);
};