The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
fix(ui): truncate LTR values at their end in RTL layouts (#27059)
almoghazaz-cellca943bf4e8a7
diff --git a/packages/twenty-front/src/modules/ui/field/display/components/__stories__/LinksDisplay.stories.tsx b/packages/twenty-front/src/modules/ui/field/display/components/__stories__/LinksDisplay.stories.tsxindex 62ced2e32d6..20645ac7ffe 100644--- a/packages/twenty-front/src/modules/ui/field/display/components/__stories__/LinksDisplay.stories.tsx+++ b/packages/twenty-front/src/modules/ui/field/display/components/__stories__/LinksDisplay.stories.tsx@@ -57,7 +57,7 @@ export const NullLinks: Story = {expect(links).toHaveLength(1);});- const validLink = await canvas.findByText('Valid Link');+ const validLink = await canvas.findByRole('link', { name: 'Valid Link' });expect(validLink).toBeVisible();expect(validLink).toHaveAttribute('href', 'https://www.twenty.com');@@ -107,15 +107,17 @@ export const MultipleLinks: Story = {expect(links).toHaveLength(3);});- const primaryLink = await canvas.findByText('Twenty Website');+ const primaryLink = await canvas.findByRole('link', {+ name: 'Twenty Website',+ });expect(primaryLink).toBeVisible();expect(primaryLink).toHaveAttribute('href', 'https://www.twenty.com');- const docsLink = await canvas.findByText('Documentation');+ const docsLink = await canvas.findByRole('link', { name: 'Documentation' });expect(docsLink).toBeVisible();expect(docsLink).toHaveAttribute('href', 'https://docs.twenty.com');- const blogLink = await canvas.findByText('Blog');+ const blogLink = await canvas.findByRole('link', { name: 'Blog' });expect(blogLink).toBeVisible();expect(blogLink).toHaveAttribute('href', 'https://blog.twenty.com');},@@ -143,21 +145,23 @@ export const SocialMediaLinks: Story = {expect(links).toHaveLength(3);});- const linkedinLink = await canvas.findByText('twenty');+ const linkedinLink = await canvas.findByRole('link', { name: 'twenty' });expect(linkedinLink).toBeVisible();expect(linkedinLink).toHaveAttribute('href','https://www.linkedin.com/company/twenty',);- const twitterLink = await canvas.findByText('@twentycrm');+ const twitterLink = await canvas.findByRole('link', { name: '@twentycrm' });expect(twitterLink).toBeVisible();expect(twitterLink).toHaveAttribute('href','https://twitter.com/twentycrm',);- const instagramLink = await canvas.findByText('@twenty_hq');+ const instagramLink = await canvas.findByRole('link', {+ name: '@twenty_hq',+ });expect(instagramLink).toBeVisible();expect(instagramLink).toHaveAttribute('href',@@ -185,7 +189,7 @@ export const InstagramLinks: Story = {expect(links).toHaveLength(3);});- const handleLink = await canvas.findByText('@twenty_hq');+ const handleLink = await canvas.findByRole('link', { name: '@twenty_hq' });expect(handleLink).toBeVisible();expect(handleLink).toHaveAttribute('href',@@ -218,14 +222,18 @@ export const SocialLinksWithCustomLabels: Story = {expect(links).toHaveLength(2);});- const linkedinLink = await canvas.findByText('Twenty on LinkedIn');+ const linkedinLink = await canvas.findByRole('link', {+ name: 'Twenty on LinkedIn',+ });expect(linkedinLink).toBeVisible();expect(linkedinLink).toHaveAttribute('href','https://www.linkedin.com/company/twenty',);- const instagramLink = await canvas.findByText('Twenty on Instagram');+ const instagramLink = await canvas.findByRole('link', {+ name: 'Twenty on Instagram',+ });expect(instagramLink).toBeVisible();expect(instagramLink).toHaveAttribute('href',@@ -250,11 +258,15 @@ export const AutomaticLabelFromURL: Story = {expect(links).toHaveLength(2);});- const primaryLink = await canvas.findByText('www.example.com');+ const primaryLink = await canvas.findByRole('link', {+ name: 'www.example.com',+ });expect(primaryLink).toBeVisible();expect(primaryLink).toHaveAttribute('href', 'https://www.example.com');- const secondaryLink = await canvas.findByText('test.example.com');+ const secondaryLink = await canvas.findByRole('link', {+ name: 'test.example.com',+ });expect(secondaryLink).toBeVisible();expect(secondaryLink).toHaveAttribute('href', 'https://test.example.com');},diff --git a/packages/twenty-front/src/modules/ui/field/display/components/__tests__/EmailsDisplay.test.tsx b/packages/twenty-front/src/modules/ui/field/display/components/__tests__/EmailsDisplay.test.tsxnew file mode 100644index 00000000000..69ef8d0a9d4--- /dev/null+++ b/packages/twenty-front/src/modules/ui/field/display/components/__tests__/EmailsDisplay.test.tsx@@ -0,0 +1,29 @@+import { i18n } from '@lingui/core';+import { I18nProvider } from '@lingui/react';+import { render, screen } from '@testing-library/react';++import { EmailsDisplay } from '@/ui/field/display/components/EmailsDisplay';++describe('EmailsDisplay', () => {+ it('lays out each email by its own direction', () => {+ render(+ <I18nProvider i18n={i18n}>+ <div dir="rtl">+ <EmailsDisplay+ value={{+ primaryEmail: '[email protected]',+ additionalEmails: ['[email protected]'],+ }}+ />+ </div>+ </I18nProvider>,+ );++ expect(+ screen.getByRole('link', { name: '[email protected]' }),+ ).toHaveAttribute('dir', 'auto');+ expect(+ screen.getByRole('link', { name: '[email protected]' }),+ ).toHaveAttribute('dir', 'auto');+ });+});diff --git a/packages/twenty-front/src/modules/ui/navigation/link/components/RoundedLink/RoundedLink.tsx b/packages/twenty-front/src/modules/ui/navigation/link/components/RoundedLink/RoundedLink.tsxindex a331484036d..8932ac224a7 100644--- a/packages/twenty-front/src/modules/ui/navigation/link/components/RoundedLink/RoundedLink.tsx+++ b/packages/twenty-front/src/modules/ui/navigation/link/components/RoundedLink/RoundedLink.tsx@@ -13,12 +13,12 @@ const StyledLink = styled.a`corner-shape: round;cursor: pointer;display: inline-flex;+ flex-shrink: 0;font-weight: var(--t-font-size-md);gap: var(--t-spacing-1);height: 10px;justify-content: center;- max-width: calc(100% - var(--t-spacing-multiplicator) * 2px);- min-width: fit-content;+ max-width: calc(100% - 2 * var(--t-spacing-2) - 2px);overflow: hidden;padding: var(--t-spacing-1) var(--t-spacing-2);text-decoration: none;@@ -39,6 +39,11 @@ const StyledLink = styled.a`}`;+const StyledLabel = styled.span`+ overflow: hidden;+ text-overflow: ellipsis;+`;+type RoundedLinkProps = {href: string;label?: string;@@ -52,7 +57,7 @@ export const RoundedLink = ({label,href,color = 'primary',- dir,+ dir = 'auto',onClick,className,}: RoundedLinkProps) => {@@ -75,7 +80,7 @@ export const RoundedLink = ({data-color={color}className={className}>- {label}+ <StyledLabel>{label}</StyledLabel></StyledLink>);};diff --git a/packages/twenty-front/src/modules/ui/navigation/link/components/RoundedLink/__tests__/RoundedLink.test.tsx b/packages/twenty-front/src/modules/ui/navigation/link/components/RoundedLink/__tests__/RoundedLink.test.tsxnew file mode 100644index 00000000000..9792b281c99--- /dev/null+++ b/packages/twenty-front/src/modules/ui/navigation/link/components/RoundedLink/__tests__/RoundedLink.test.tsx@@ -0,0 +1,51 @@+import { render, screen } from '@testing-library/react';++import { RoundedLink } from '@/ui/navigation/link/components/RoundedLink/RoundedLink';++describe('RoundedLink', () => {+ it('lays out its label by the label direction by default', () => {+ render(+ <div dir="rtl">+ <RoundedLink+ href="mailto:[email protected]"+ label="[email protected]"+ />+ </div>,+ );++ expect(+ screen.getByRole('link', { name: '[email protected]' }),+ ).toHaveAttribute('dir', 'auto');+ });++ it('forwards an explicit direction', () => {+ render(+ <RoundedLink+ href="tel:+972521234567"+ label="+972 52 123 4567"+ dir="ltr"+ />,+ );++ expect(+ screen.getByRole('link', { name: '+972 52 123 4567' }),+ ).toHaveAttribute('dir', 'ltr');+ });++ it('renders the label in its own element so it can be ellipsized inside the chip', () => {+ render(+ <RoundedLink+ href="mailto:[email protected]"+ label="[email protected]"+ />,+ );++ const link = screen.getByRole('link', {+ name: '[email protected]',+ });+ const label = screen.getByText('[email protected]');++ expect(label).not.toBe(link);+ expect(link).toContainElement(label);+ });+});diff --git a/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/OverflowingTextWithTooltip.tsx b/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/OverflowingTextWithTooltip.tsxindex 8c4d09d91f5..dab6e6833f1 100644--- a/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/OverflowingTextWithTooltip.tsx+++ b/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/OverflowingTextWithTooltip.tsx@@ -101,6 +101,7 @@ export const OverflowingTextWithTooltip = memo({...(isMultiline? { lineClamp }: { truncate: truncate ?? true })}+ dir="auto"data-content-overflowing={isTitleOverflowing ? '' : undefined}className={clsx(isMultilinediff --git a/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/__tests__/OverflowingTextWithTooltip.test.tsx b/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/__tests__/OverflowingTextWithTooltip.test.tsxindex 688b236724f..0dcdae6ad59 100644--- a/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/__tests__/OverflowingTextWithTooltip.test.tsx+++ b/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/__tests__/OverflowingTextWithTooltip.test.tsx@@ -272,4 +272,19 @@ describe('OverflowingTextWithTooltip', () => {expect(screen.queryByRole('tooltip')).not.toBeInTheDocument();});});++ it('lays out each value by its own direction', () => {+ render(+ <div dir="rtl">+ <OverflowingTextWithTooltip text="Enterprise Workstation Refresh" />+ <OverflowingTextWithTooltip text="הטמעת CRM לאקמה" />+ </div>,+ );++ expect(screen.getByText('Enterprise Workstation Refresh')).toHaveAttribute(+ 'dir',+ 'auto',+ );+ expect(screen.getByText('הטמעת CRM לאקמה')).toHaveAttribute('dir', 'auto');+ });});