Skip to content

The open alternative to Salesforce, designed for AI.

fix(front): lay phone numbers out left to right in RTL locales (#27006)

almoghazaz-cellbd68a3dfd7d8
diff --git a/packages/twenty-front/src/modules/ui/field/display/components/PhonesDisplay.tsx b/packages/twenty-front/src/modules/ui/field/display/components/PhonesDisplay.tsx
index 229784634d7..93c2190730a 100644
--- a/packages/twenty-front/src/modules/ui/field/display/components/PhonesDisplay.tsx
+++ b/packages/twenty-front/src/modules/ui/field/display/components/PhonesDisplay.tsx
@@ -62,6 +62,7 @@ export const PhonesDisplay = ({
<RoundedLink
key={index}
href={URI || ''}
+ dir="ltr"
label={
parsedPhone ? parsedPhone.formatInternational() : invalidPhone
}
@@ -82,6 +83,7 @@ export const PhonesDisplay = ({
<RoundedLink
key={index}
href={URI || ''}
+ dir="ltr"
label={
parsedPhone ? parsedPhone.formatInternational() : invalidPhone
}
diff --git a/packages/twenty-front/src/modules/ui/field/display/components/__tests__/PhoneDisplay.test.tsx b/packages/twenty-front/src/modules/ui/field/display/components/__tests__/PhoneDisplay.test.tsx
new file mode 100644
index 00000000000..01e71785de1
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/field/display/components/__tests__/PhoneDisplay.test.tsx
@@ -0,0 +1,17 @@
+import { render, screen } from '@testing-library/react';
+
+import { PhoneDisplay } from '@/ui/field/display/components/PhoneDisplay';
+
+describe('PhoneDisplay', () => {
+ it('lays the phone number out left to right', () => {
+ render(
+ <div dir="rtl">
+ <PhoneDisplay value={{ number: '521234567', callingCode: '+972' }} />
+ </div>,
+ );
+
+ expect(
+ screen.getByRole('link', { name: '+972 52 123 4567' }),
+ ).toHaveAttribute('dir', 'ltr');
+ });
+});
diff --git a/packages/twenty-front/src/modules/ui/field/display/components/__tests__/PhonesDisplay.test.tsx b/packages/twenty-front/src/modules/ui/field/display/components/__tests__/PhonesDisplay.test.tsx
new file mode 100644
index 00000000000..9c7cdfbead8
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/field/display/components/__tests__/PhonesDisplay.test.tsx
@@ -0,0 +1,36 @@
+import { i18n } from '@lingui/core';
+import { I18nProvider } from '@lingui/react';
+import { render, screen } from '@testing-library/react';
+
+import { PhonesDisplay } from '@/ui/field/display/components/PhonesDisplay';
+
+describe('PhonesDisplay', () => {
+ it('lays each phone number out left to right', () => {
+ render(
+ <I18nProvider i18n={i18n}>
+ <div dir="rtl">
+ <PhonesDisplay
+ value={{
+ primaryPhoneNumber: '521234567',
+ primaryPhoneCountryCode: 'IL',
+ primaryPhoneCallingCode: '+972',
+ additionalPhones: [
+ { number: '2071234567', callingCode: '+44', countryCode: 'GB' },
+ ],
+ }}
+ />
+ </div>
+ </I18nProvider>,
+ );
+
+ const primaryPhone = screen.getByRole('link', {
+ name: '+972 52 123 4567',
+ });
+ const additionalPhone = screen.getByRole('link', {
+ name: '+44 20 7123 4567',
+ });
+
+ expect(primaryPhone).toHaveAttribute('dir', 'ltr');
+ expect(additionalPhone).toHaveAttribute('dir', 'ltr');
+ });
+});
diff --git a/packages/twenty-front/src/modules/ui/field/display/components/internal/ContactLink/ContactLink.tsx b/packages/twenty-front/src/modules/ui/field/display/components/internal/ContactLink/ContactLink.tsx
index ff99b0e50ed..1fd0be9a8b4 100644
--- a/packages/twenty-front/src/modules/ui/field/display/components/internal/ContactLink/ContactLink.tsx
+++ b/packages/twenty-front/src/modules/ui/field/display/components/internal/ContactLink/ContactLink.tsx
@@ -42,6 +42,7 @@ export const ContactLink = ({
} as React.CSSProperties
}
target="_blank"
+ dir="ltr"
onClick={onClick}
href={getSafeUrl(href)}
>
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.tsx
index a632c8e328b..a331484036d 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
@@ -43,6 +43,7 @@ type RoundedLinkProps = {
href: string;
label?: string;
color?: 'primary' | 'secondary';
+ dir?: 'ltr' | 'rtl' | 'auto';
onClick?: (event: React.MouseEvent<HTMLElement>) => void;
className?: string;
};
@@ -51,6 +52,7 @@ export const RoundedLink = ({
label,
href,
color = 'primary',
+ dir,
onClick,
className,
}: RoundedLinkProps) => {
@@ -68,6 +70,7 @@ export const RoundedLink = ({
href={getSafeUrl(href)}
target="_blank"
rel="noreferrer"
+ dir={dir}
onClick={handleClick}
data-color={color}
className={className}