Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/pretty-walls-burn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@clerk/localizations': patch
'@clerk/clerk-js': patch
'@clerk/types': patch
---

Localize aria-labels within `UserButton` and `OrganizationSwitcher` triggers.
2 changes: 1 addition & 1 deletion integration/tests/next-quickstart.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ testAgainstRunningApps({ withEnv: [appConfigs.envs.withEmailCodesQuickstart] })(
await u.po.expect.toBeSignedIn();
await u.po.userButton.waitForMounted();

await expect(u.page.getByRole('button', { name: /Open user button/i })).toBeVisible();
await expect(u.page.getByRole('button', { name: /Open user menu/i })).toBeVisible();
});

test('user button is functional after sign in', async ({ page, context }) => {
Expand Down
2 changes: 1 addition & 1 deletion integration/tests/sign-out-smoke.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ testAgainstRunningApps({ withEnv: [appConfigs.envs.withEmailCodes] })('sign out
await u.page.getByRole('link', { name: 'Protected', exact: true }).click();
await u.page.getByTestId('protected').waitFor();
await u.page.getByRole('link', { name: 'Home' }).click();
await u.page.getByRole('button', { name: 'Open user button' }).click();
await u.page.getByRole('button', { name: 'Open user menu' }).click();

await u.page.getByRole('menuitem', { name: 'Sign out' }).click();
await u.page.getByRole('link', { name: 'Protected', exact: true }).click();
Expand Down
2 changes: 1 addition & 1 deletion integration/tests/user-profile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export default function Page() {
await u.page.goToRelative('/');
await u.page.waitForClerkComponentMounted();

await u.page.getByRole('button', { name: 'Open user button' }).click();
await u.page.getByRole('button', { name: 'Open user menu' }).click();

await u.page.getByText(/Manage account/).click();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { useOrganization, useOrganizationList, useUser } from '@clerk/shared/react';
import { forwardRef } from 'react';

import { OrganizationPreview } from '@/ui/elements/OrganizationPreview';
import { PersonalWorkspacePreview } from '@/ui/elements/PersonalWorkspacePreview';
import { withAvatarShimmer } from '@/ui/elements/withAvatarShimmer';

import { NotificationCountBadge, useProtect } from '../../common';
import { useEnvironment, useOrganizationSwitcherContext } from '../../contexts';
import { Button, descriptors, Icon, localizationKeys } from '../../customizables';
import { Button, descriptors, Icon, localizationKeys, useLocalizations } from '../../customizables';
import { ChevronDown } from '../../icons';
import type { PropsOfComponent } from '../../styledSystem';
import { organizationListParams } from './utils';
Expand All @@ -23,6 +22,7 @@ export const OrganizationSwitcherTrigger = withAvatarShimmer(
const { user } = useUser();
const { organization } = useOrganization();
const { hidePersonal } = useOrganizationSwitcherContext();
const { t } = useLocalizations();

if (!user) {
return null;
Expand All @@ -46,20 +46,11 @@ export const OrganizationSwitcherTrigger = withAvatarShimmer(
sx,
]}
ref={ref}
aria-label={`${props.isOpen ? 'Close' : 'Open'} organization switcher`}
aria-label={`${props.isOpen ? t(localizationKeys('organizationSwitcher.action__closeOrganizationSwitcher')) : t(localizationKeys('organizationSwitcher.action__openOrganizationSwitcher'))}`}
aria-expanded={props.isOpen}
aria-haspopup='dialog'
{...rest}
>
{organization && (

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like it is causing the bug I'm seeing right now potentially. Where the organization name is never displayed.

<OrganizationPreview
elementId={'organizationSwitcherTrigger'}
gap={3}
size='xs'
organization={organization}
sx={{ maxWidth: '30ch' }}
/>
)}
{!organization && (
<PersonalWorkspacePreview
size='xs'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { UserAvatar } from '@/ui/elements/UserAvatar';
import { withAvatarShimmer } from '@/ui/elements/withAvatarShimmer';

import { useUserButtonContext } from '../../contexts';
import { Button, descriptors, Flex } from '../../customizables';
import { Button, descriptors, Flex, localizationKeys, useLocalizations } from '../../customizables';
import type { PropsOfComponent } from '../../styledSystem';
import { UserButtonTopLevelIdentifier } from './UserButtonTopLevelIdentifier';

Expand All @@ -18,14 +18,15 @@ export const UserButtonTrigger = withAvatarShimmer(
const { sx, ...rest } = props;
const { user } = useUser();
const { showName } = useUserButtonContext();
const { t } = useLocalizations();

return (
<Button
elementDescriptor={descriptors.userButtonTrigger}
variant='roundWrapper'
sx={[t => ({ borderRadius: showName ? t.radii.$md : t.radii.$circle, color: t.colors.$colorForeground }), sx]}
ref={ref}
aria-label={`${props.isOpen ? 'Close' : 'Open'} user button`}
aria-label={`${props.isOpen ? t(localizationKeys('userButton.action__closeUserMenu')) : t(localizationKeys('userButton.action__openUserMenu'))}`}
aria-expanded={props.isOpen}
aria-haspopup='dialog'
{...rest}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('UserButton', () => {
__experimental_asStandalone: true,
});
const { getByText, queryByRole } = render(<UserButton />, { wrapper });
expect(queryByRole('button', { name: 'Open user button' })).toBeNull();
expect(queryByRole('button', { name: 'Open user menu' })).toBeNull();
getByText('Manage account');
});

Expand All @@ -44,7 +44,7 @@ describe('UserButton', () => {
});
});
const { getByText, getByRole, userEvent } = render(<UserButton />, { wrapper });
await userEvent.click(getByRole('button', { name: 'Open user button' }));
await userEvent.click(getByRole('button', { name: 'Open user menu' }));
expect(getByText('Manage account')).not.toBeNull();
});

Expand All @@ -58,7 +58,7 @@ describe('UserButton', () => {
});
});
const { getByText, getByRole, userEvent } = render(<UserButton />, { wrapper });
await userEvent.click(getByRole('button', { name: 'Open user button' }));
await userEvent.click(getByRole('button', { name: 'Open user menu' }));
await userEvent.click(getByText('Manage account'));
expect(fixtures.clerk.openUserProfile).toHaveBeenCalled();
});
Expand All @@ -76,7 +76,7 @@ describe('UserButton', () => {
fixtures.clerk.signOut.mockImplementationOnce(callback => callback());

const { getByText, getByRole, userEvent } = render(<UserButton />, { wrapper });
await userEvent.click(getByRole('button', { name: 'Open user button' }));
await userEvent.click(getByRole('button', { name: 'Open user menu' }));
await userEvent.click(getByText('Sign out'));

expect(fixtures.router.navigate).toHaveBeenCalledWith('/');
Expand All @@ -96,7 +96,7 @@ describe('UserButton', () => {
props.setProps({ afterSignOutUrl: '/after-sign-out' });

const { getByText, getByRole, userEvent } = render(<UserButton />, { wrapper });
await userEvent.click(getByRole('button', { name: 'Open user button' }));
await userEvent.click(getByRole('button', { name: 'Open user menu' }));
await userEvent.click(getByText('Sign out'));

expect(fixtures.router.navigate).toHaveBeenCalledWith('/after-sign-out');
Expand Down Expand Up @@ -133,7 +133,7 @@ describe('UserButton', () => {
it('renders all sessions', async () => {
const { wrapper } = await createFixtures(initConfig);
const { getByText, getByRole, userEvent } = render(<UserButton />, { wrapper });
await userEvent.click(getByRole('button', { name: 'Open user button' }));
await userEvent.click(getByRole('button', { name: 'Open user menu' }));
expect(getByText('First1 Last1')).toBeDefined();
expect(getByText('First2 Last2')).toBeDefined();
expect(getByText('First3 Last3')).toBeDefined();
Expand All @@ -143,7 +143,7 @@ describe('UserButton', () => {
const { wrapper, fixtures } = await createFixtures(initConfig);
fixtures.clerk.setActive.mockReturnValueOnce(Promise.resolve());
const { getByText, getByRole, userEvent } = render(<UserButton />, { wrapper });
await userEvent.click(getByRole('button', { name: 'Open user button' }));
await userEvent.click(getByRole('button', { name: 'Open user menu' }));
await userEvent.click(getByText('First3 Last3'));
expect(fixtures.clerk.setActive).toHaveBeenCalledWith(
expect.objectContaining({ session: expect.objectContaining({ user: expect.objectContaining({ id: '3' }) }) }),
Expand All @@ -156,7 +156,7 @@ describe('UserButton', () => {
return Promise.resolve(callback());
});
const { getByText, getByRole, userEvent } = render(<UserButton />, { wrapper });
await userEvent.click(getByRole('button', { name: 'Open user button' }));
await userEvent.click(getByRole('button', { name: 'Open user menu' }));
await userEvent.click(getByText('Sign out'));
await waitFor(() => {
expect(fixtures.clerk.signOut).toHaveBeenCalledWith(expect.any(Function), { sessionId: '0' });
Expand All @@ -170,7 +170,7 @@ describe('UserButton', () => {
return Promise.resolve(callback());
});
const { getByText, getByRole, userEvent } = render(<UserButton />, { wrapper });
await userEvent.click(getByRole('button', { name: 'Open user button' }));
await userEvent.click(getByRole('button', { name: 'Open user menu' }));
await userEvent.click(getByText('Sign out of all accounts'));
await waitFor(() => {
expect(fixtures.clerk.signOut).toHaveBeenCalledWith(expect.any(Function));
Expand Down
4 changes: 4 additions & 0 deletions packages/localizations/src/ar-SA.ts
Original file line number Diff line number Diff line change
Expand Up @@ -487,9 +487,11 @@ export const arSA: LocalizationResource = {
},
},
organizationSwitcher: {
action__closeOrganizationSwitcher: undefined,
action__createOrganization: 'أنشاء منظمة',
action__invitationAccept: 'أنضمام',
action__manageOrganization: 'أدارة المنظمة',
action__openOrganizationSwitcher: undefined,
action__suggestionsAccept: 'طلب أنضمام',
notSelected: 'لم يتم أختيار منظمة',
personalWorkspace: 'الحساب الشخصي',
Expand Down Expand Up @@ -938,7 +940,9 @@ export const arSA: LocalizationResource = {
},
userButton: {
action__addAccount: 'إضافة حساب',
action__closeUserMenu: 'إغلاق قائمة المستخدم',
action__manageAccount: 'إدارة الحساب',
action__openUserMenu: 'فتح قائمة المستخدم',
action__signOut: 'تسجيل الخروج',
action__signOutAll: 'تسجيل الخروج من جميع الحسابات',
},
Expand Down
4 changes: 4 additions & 0 deletions packages/localizations/src/be-BY.ts
Original file line number Diff line number Diff line change
Expand Up @@ -493,9 +493,11 @@ export const beBY: LocalizationResource = {
},
},
organizationSwitcher: {
action__closeOrganizationSwitcher: undefined,
action__createOrganization: 'Стварыць арганізацыю',
action__invitationAccept: 'Join',
action__manageOrganization: 'Кіраванне арганізацыяй',
action__openOrganizationSwitcher: undefined,
action__suggestionsAccept: 'Request to join',
notSelected: 'Арганізацыя не выбрана',
personalWorkspace: 'Асабістае працоўнае прастора',
Expand Down Expand Up @@ -947,7 +949,9 @@ export const beBY: LocalizationResource = {
},
userButton: {
action__addAccount: 'Дадаць уліковы запіс',
action__closeUserMenu: undefined,
action__manageAccount: 'Кіраванне ўліковым запісам',
action__openUserMenu: undefined,
action__signOut: 'Выйсці',
action__signOutAll: 'Выйсці з усіх уліковых запісаў',
},
Expand Down
4 changes: 4 additions & 0 deletions packages/localizations/src/bg-BG.ts
Original file line number Diff line number Diff line change
Expand Up @@ -490,9 +490,11 @@ export const bgBG: LocalizationResource = {
},
},
organizationSwitcher: {
action__closeOrganizationSwitcher: undefined,
action__createOrganization: 'Създаване на организация',
action__invitationAccept: 'Присъединяване',
action__manageOrganization: 'Управление',
action__openOrganizationSwitcher: undefined,
action__suggestionsAccept: 'Заявка за присъединяване',
notSelected: 'Няма избрана организация',
personalWorkspace: 'Личен акаунт',
Expand Down Expand Up @@ -939,7 +941,9 @@ export const bgBG: LocalizationResource = {
},
userButton: {
action__addAccount: 'Добавяне на акаунт',
action__closeUserMenu: undefined,
action__manageAccount: 'Управление на акаунта',
action__openUserMenu: undefined,
action__signOut: 'Изход',
action__signOutAll: 'Изход от всички акаунти',
},
Expand Down
4 changes: 4 additions & 0 deletions packages/localizations/src/bn-IN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -490,9 +490,11 @@ export const bnIN: LocalizationResource = {
},
},
organizationSwitcher: {
action__closeOrganizationSwitcher: undefined,
action__createOrganization: 'সংগঠন তৈরি করুন',
action__invitationAccept: 'যোগ দিন',
action__manageOrganization: 'পরিচালনা',
action__openOrganizationSwitcher: undefined,
action__suggestionsAccept: 'যোগ দেওয়ার অনুরোধ করুন',
notSelected: 'কোনো সংগঠন নির্বাচিত নেই',
personalWorkspace: 'ব্যক্তিগত অ্যাকাউন্ট',
Expand Down Expand Up @@ -950,7 +952,9 @@ export const bnIN: LocalizationResource = {
},
userButton: {
action__addAccount: 'অ্যাকাউন্ট যোগ করুন',
action__closeUserMenu: 'ব্যবহারকারী মেনু বন্ধ করুন',
action__manageAccount: 'অ্যাকাউন্ট পরিচালনা করুন',
action__openUserMenu: 'ব্যবহারকারী মেনু খুলুন',
action__signOut: 'সাইন আউট',
action__signOutAll: 'সব অ্যাকাউন্ট থেকে সাইন আউট করুন',
},
Expand Down
4 changes: 4 additions & 0 deletions packages/localizations/src/ca-ES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -490,9 +490,11 @@ export const caES: LocalizationResource = {
},
},
organizationSwitcher: {
action__closeOrganizationSwitcher: undefined,
action__createOrganization: 'Crea organització',
action__invitationAccept: 'Uneix-te',
action__manageOrganization: 'Gestiona',
action__openOrganizationSwitcher: undefined,
action__suggestionsAccept: 'Sol·licita unir-te',
notSelected: "No s'ha seleccionat cap organització",
personalWorkspace: 'Compte personal',
Expand Down Expand Up @@ -942,7 +944,9 @@ export const caES: LocalizationResource = {
},
userButton: {
action__addAccount: 'Afegeix compte',
action__closeUserMenu: undefined,
action__manageAccount: 'Gestiona compte',
action__openUserMenu: undefined,
action__signOut: 'Tanca sessió',
action__signOutAll: 'Tanca sessió de tots els comptes',
},
Expand Down
4 changes: 4 additions & 0 deletions packages/localizations/src/cs-CZ.ts
Original file line number Diff line number Diff line change
Expand Up @@ -494,9 +494,11 @@ export const csCZ: LocalizationResource = {
},
},
organizationSwitcher: {
action__closeOrganizationSwitcher: undefined,
action__createOrganization: 'Vytvořit organizaci',
action__invitationAccept: 'Připojit se',
action__manageOrganization: 'Spravovat organizaci',
action__openOrganizationSwitcher: undefined,
action__suggestionsAccept: 'Požádat o připojení',
notSelected: 'Není vybrána žádná organizace',
personalWorkspace: 'Osobní účet',
Expand Down Expand Up @@ -951,7 +953,9 @@ export const csCZ: LocalizationResource = {
},
userButton: {
action__addAccount: 'Přidat účet',
action__closeUserMenu: undefined,
action__manageAccount: 'Spravovat účet',
action__openUserMenu: undefined,
action__signOut: 'Odhlásit se',
action__signOutAll: 'Odhlásit se ze všech účtů',
},
Expand Down
4 changes: 4 additions & 0 deletions packages/localizations/src/da-DK.ts
Original file line number Diff line number Diff line change
Expand Up @@ -489,9 +489,11 @@ export const daDK: LocalizationResource = {
},
},
organizationSwitcher: {
action__closeOrganizationSwitcher: undefined,
action__createOrganization: 'Opret organisation',
action__invitationAccept: 'Deltag',
action__manageOrganization: 'Administrer organisation',
action__openOrganizationSwitcher: undefined,
action__suggestionsAccept: 'Anmod om at deltage',
notSelected: 'Ingen organisation valgt',
personalWorkspace: 'Personligt arbejdsområde',
Expand Down Expand Up @@ -938,7 +940,9 @@ export const daDK: LocalizationResource = {
},
userButton: {
action__addAccount: 'Tilføj konto',
action__closeUserMenu: undefined,
action__manageAccount: 'Administrer konto',
action__openUserMenu: undefined,
action__signOut: 'Log ud',
action__signOutAll: 'Log ud af alle konti',
},
Expand Down
4 changes: 4 additions & 0 deletions packages/localizations/src/de-DE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -500,9 +500,11 @@ export const deDE: LocalizationResource = {
},
},
organizationSwitcher: {
action__closeOrganizationSwitcher: undefined,
action__createOrganization: 'Organisation erstellen',
action__invitationAccept: 'Beitreten',
action__manageOrganization: 'Organisation verwalten',
action__openOrganizationSwitcher: undefined,
action__suggestionsAccept: 'Beitritt anfragen',
notSelected: 'Keine Organisation ausgewählt',
personalWorkspace: 'Persönlicher Arbeitsbereich',
Expand Down Expand Up @@ -967,7 +969,9 @@ export const deDE: LocalizationResource = {
},
userButton: {
action__addAccount: 'Konto hinzufügen',
action__closeUserMenu: 'Benutzermenü schließen',
action__manageAccount: 'Konto verwalten',
action__openUserMenu: 'Benutzermenü öffnen',
action__signOut: 'Abmelden',
action__signOutAll: 'Melden Sie sich von allen Konten ab',
},
Expand Down
4 changes: 4 additions & 0 deletions packages/localizations/src/el-GR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -489,9 +489,11 @@ export const elGR: LocalizationResource = {
},
},
organizationSwitcher: {
action__closeOrganizationSwitcher: undefined,
action__createOrganization: 'Δημιουργία Οργανισμού',
action__invitationAccept: 'Join',
action__manageOrganization: 'Διαχείριση Οργανισμού',
action__openOrganizationSwitcher: undefined,
action__suggestionsAccept: 'Request to join',
notSelected: 'Δεν έχει επιλεγεί οργανισμός',
personalWorkspace: 'Προσωπικός Χώρος Εργασίας',
Expand Down Expand Up @@ -946,7 +948,9 @@ export const elGR: LocalizationResource = {
},
userButton: {
action__addAccount: 'Προσθήκη λογαριασμού',
action__closeUserMenu: undefined,
action__manageAccount: 'Διαχείριση λογαριασμού',
action__openUserMenu: undefined,
action__signOut: 'Αποσύνδεση',
action__signOutAll: 'Αποσύνδεση από όλους τους λογαριασμούς',
},
Expand Down
Loading
Loading