Skip to content

Commit

Permalink
fix: properly switch between 12 and 24 word inputs, closes #4250
Browse files Browse the repository at this point in the history
  • Loading branch information
pete-watters authored and fbwoolf committed Oct 13, 2023
1 parent 230fe46 commit 1a86b85
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
16 changes: 10 additions & 6 deletions src/app/pages/onboarding/sign-in/sign-in.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from 'react';
import { useEffect, useState } from 'react';
import { useNavigate } from 'react-router-dom';

import { RouteUrls } from '@shared/route-urls';
Expand All @@ -15,19 +15,23 @@ export function SignIn() {
const navigate = useNavigate();

const [twentyFourWordMode, setTwentyFourWordMode] = useState(true);
const [mnemonic, setMnemonic] = useState<(string | null)[]>(() => createNullArrayOfLength(24));
const [mnemonic, setMnemonic] = useState<(string | null)[]>([]);

useRouteHeader(<Header onClose={() => navigate(RouteUrls.Onboarding)} hideActions />);

useEffect(() => {
const emptyMnemonicArray = twentyFourWordMode
? createNullArrayOfLength(24)
: createNullArrayOfLength(12);
setMnemonic(emptyMnemonicArray);
}, [twentyFourWordMode]);

return (
<>
<TwoColumnLayout
leftColumn={
<SignInContent
onClick={() => {
setTwentyFourWordMode(!twentyFourWordMode);
setMnemonic(createNullArrayOfLength(twentyFourWordMode ? 24 : 12));
}}
onClick={() => setTwentyFourWordMode(!twentyFourWordMode)}
twentyFourWordMode={twentyFourWordMode}
/>
}
Expand Down
2 changes: 0 additions & 2 deletions tests/specs/onboarding/onboarding.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,10 @@ test.describe('Onboarding an existing user', () => {
// enter some key partial
const validPartialKey = 'shoulder any pencil';
await onboardingPage.signInMnemonicKey(validPartialKey);
const signInButton = await onboardingPage.page.getByTestId(OnboardingSelectors.SignInBtn);
const signInSeedError = await onboardingPage.page.getByTestId(
OnboardingSelectors.SignInSeedError
);
await test.expect(signInSeedError).not.toBeVisible();
await test.expect(signInButton).toBeDisabled();
});

test('Activity tab', async ({ extensionId, globalPage, onboardingPage, homePage }) => {
Expand Down

0 comments on commit 1a86b85

Please sign in to comment.