Skip to content

Commit 3c07da9

Browse files
fix(mosaic): close the identifier menu once primary reverification opens
Set as primary stayed pending while the session verification dialog was open, so its menu stayed open with a spinner behind the dialog. The pending status now ends when the dialog appears, as ActionMenu expects.
1 parent afdd068 commit 3c07da9

7 files changed

Lines changed: 14 additions & 3 deletions

File tree

‎packages/mosaic/src/features/user-profile/user-profile-email-section/__tests__/user-profile-email-section.feature.test.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ describe('email reverification', () => {
344344

345345
await manageEmail(actor, 'bob@example.com', 'Set as primary');
346346
expect(await screen.findByText('Enter your current password to continue')).toBeVisible();
347+
await waitFor(() => expect(screen.queryByRole('menu', { hidden: true })).toBeNull());
347348
await waitFor(() => expect(screen.getByLabelText('Password')).toHaveFocus());
348349
await actor.keyboard('hunter2{Enter}');
349350

‎packages/mosaic/src/features/user-profile/user-profile-email-section/user-profile-email-section.controller.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export function useUserProfileEmailSectionController({
3939
emails: emails.map(email => ({
4040
...email,
4141
isVerifyPending: verification.pendingVerifyId === email.id,
42-
isPrimaryPending: actions.pendingKey === email.id,
42+
isPrimaryPending: actions.pendingKey === email.id && !setPrimaryReverification.visible,
4343
})),
4444
canAdd: Boolean(onCreateEmail),
4545
verification,

‎packages/mosaic/src/features/user-profile/user-profile-phone-section/__tests__/user-profile-phone-section.feature.test.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,7 @@ describe('phone reverification', () => {
485485

486486
await manage(actor, WORK_LABEL, 'Set as primary');
487487
expect(await screen.findByText('Enter your current password to continue')).toBeVisible();
488+
await waitFor(() => expect(screen.queryByRole('menu', { hidden: true })).toBeNull());
488489
await waitFor(() => expect(screen.getByLabelText('Password')).toHaveFocus());
489490
await actor.keyboard('hunter2{Enter}');
490491

‎packages/mosaic/src/features/user-profile/user-profile-phone-section/user-profile-phone-section.controller.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export function useUserProfilePhoneSectionController({
4040
...phone,
4141
value: stringToFormattedPhoneString(phone.value),
4242
isVerifyPending: verification.pendingVerifyId === phone.id,
43-
isPrimaryPending: actions.pendingKey === phone.id,
43+
isPrimaryPending: actions.pendingKey === phone.id && !setPrimaryReverification.visible,
4444
})),
4545
defaultPhoneCountry,
4646
canAdd: Boolean(onCreatePhone),

‎packages/mosaic/src/features/user-profile/user-profile-web3-wallets-section/__tests__/user-profile-web3-wallets-section.controller.test.tsx‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { act, renderHook } from '@testing-library/react';
22
import { describe, expect, it, vi } from 'vitest';
33

44
import { deferred } from '../../../../__tests__/async';
5+
import type { ReverificationController } from '../../../reverification';
56
import { useUserProfileWeb3WalletsController } from '../user-profile-web3-wallets-section.controller';
67
import type {
78
ReadyWeb3WalletsModel,
@@ -14,6 +15,8 @@ const providers = [
1415
{ id: 'web3_solana_signature', provider: 'Solana', walletPicker: 'solana' },
1516
] satisfies UserProfileWeb3Provider[];
1617

18+
const idleReverification = { status: 'idle', visible: false } satisfies ReverificationController;
19+
1720
function pendingRowId(controller: ReturnType<typeof useUserProfileWeb3WalletsController>) {
1821
return [...controller.wallets, ...controller.availableProviders].find(row => row.isPending)?.id;
1922
}
@@ -73,6 +76,7 @@ describe('Web3 connection controller', () => {
7376
verify: vi.fn(),
7477
setPrimary,
7578
remove: vi.fn(),
79+
setPrimaryReverification: idleReverification,
7680
}),
7781
);
7882

‎packages/mosaic/src/features/user-profile/user-profile-web3-wallets-section/__tests__/user-profile-web3-wallets-section.feature.test.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,7 @@ describe('Web3 wallets', () => {
601601
await openMenu(user, secondManage());
602602
await user.click(screen.getByRole('menuitem', { name: 'Set as primary' }));
603603
expect(await screen.findByText('Enter your current password to continue')).toBeVisible();
604+
await waitFor(() => expect(screen.queryByRole('menu', { hidden: true })).toBeNull());
604605
await waitFor(() => expect(screen.getByLabelText('Password')).toHaveFocus());
605606
await user.keyboard('hunter2{Enter}');
606607

‎packages/mosaic/src/features/user-profile/user-profile-web3-wallets-section/user-profile-web3-wallets-section.controller.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,11 @@ export function useUserProfileWeb3WalletsController({
151151
return {
152152
wallets: wallets.map(wallet => {
153153
const isPending = pendingId === wallet.id;
154-
const row = { ...wallet, isPending, isPrimaryPending: isPending && owner?.kind === 'primary' };
154+
const row = {
155+
...wallet,
156+
isPending,
157+
isPrimaryPending: isPending && owner?.kind === 'primary' && !setPrimaryReverification.visible,
158+
};
155159
return errorId === wallet.id
156160
? owner?.kind === 'primary'
157161
? { ...row, primaryError: action.error }

0 commit comments

Comments
 (0)