Command menu overflow ellipsis (#10977)

Fixes https://github.com/twentyhq/core-team-issues/issues/579
This commit is contained in:
Guillim
2025-03-18 14:21:47 +01:00
committed by GitHub
parent be1b877868
commit 6255207aa3
2 changed files with 9 additions and 1 deletions

View File

@ -1,10 +1,12 @@
import styled from '@emotion/styled'; import styled from '@emotion/styled';
import { isNonEmptyString } from '@sniptt/guards'; import { isNonEmptyString } from '@sniptt/guards';
import { OverflowingTextWithTooltip } from '@ui/display';
import { Fragment } from 'react/jsx-runtime'; import { Fragment } from 'react/jsx-runtime';
import { isDefined } from 'twenty-shared'; import { isDefined } from 'twenty-shared';
const StyledChip = styled.button<{ const StyledChip = styled.button<{
withText: boolean; withText: boolean;
maxWidth?: string;
onClick?: () => void; onClick?: () => void;
}>` }>`
all: unset; all: unset;
@ -33,6 +35,7 @@ const StyledChip = styled.button<{
? theme.background.transparent.medium ? theme.background.transparent.medium
: theme.background.transparent.light}; : theme.background.transparent.light};
} }
max-width: ${({ maxWidth }) => maxWidth};
`; `;
const StyledIconsContainer = styled.div` const StyledIconsContainer = styled.div`
@ -45,6 +48,7 @@ export type CommandMenuContextChipProps = {
text?: string; text?: string;
onClick?: () => void; onClick?: () => void;
testId?: string; testId?: string;
maxWidth?: string;
}; };
export const CommandMenuContextChip = ({ export const CommandMenuContextChip = ({
@ -52,19 +56,21 @@ export const CommandMenuContextChip = ({
text, text,
onClick, onClick,
testId, testId,
maxWidth,
}: CommandMenuContextChipProps) => { }: CommandMenuContextChipProps) => {
return ( return (
<StyledChip <StyledChip
withText={isNonEmptyString(text)} withText={isNonEmptyString(text)}
onClick={onClick} onClick={onClick}
data-testid={testId} data-testid={testId}
maxWidth={maxWidth}
> >
<StyledIconsContainer> <StyledIconsContainer>
{Icons.map((Icon, index) => ( {Icons.map((Icon, index) => (
<Fragment key={index}>{Icon}</Fragment> <Fragment key={index}>{Icon}</Fragment>
))} ))}
</StyledIconsContainer> </StyledIconsContainer>
{text && <span>{text}</span>} {text && <OverflowingTextWithTooltip text={text} />}
</StyledChip> </StyledChip>
); );
}; };

View File

@ -27,6 +27,7 @@ export const CommandMenuContextChipGroups = ({
{contextChips.map((chip, index) => ( {contextChips.map((chip, index) => (
<CommandMenuContextChip <CommandMenuContextChip
key={index} key={index}
maxWidth={'180px'}
Icons={chip.Icons} Icons={chip.Icons}
text={chip.text} text={chip.text}
onClick={chip.onClick} onClick={chip.onClick}
@ -79,6 +80,7 @@ export const CommandMenuContextChipGroups = ({
Icons={lastChip.Icons} Icons={lastChip.Icons}
text={lastChip.text} text={lastChip.text}
onClick={lastChip.onClick} onClick={lastChip.onClick}
maxWidth={'180px'}
/> />
)} )}
</> </>