Skip to content

Conversation

danblackadder
Copy link
Contributor

@danblackadder danblackadder commented Sep 30, 2025

Motivation

We are updating the account flow to handle default accounts with a single button for "Continue" and altering the way we handle the multiple account option

Changes

  • Update Checkbox to correctly handle a disabled state on hover
  • Add Toggle.Svelte
  • Update create within CreateAccount.svelte to handle a default option
  • Add EditAccount.svelte view which is currently hidden behind the feature flag
  • Add editAccount to accounts route
  • Update text and components across the auth flow hidden behind the feature flag
  • Get defaultAccount added to account/page.ts

Tests

All testing has been done by eye on Windows with Chrome - e2e to be updated once feature flag is to be switched off

"hover:bg-bg-primary_hover",
"has-checked:bg-bg-brand-solid has-checked:hover:bg-bg-brand-solid_hover has-checked:border-none",
"has-disabled:border-border-disabled has-disabled:bg-bg-disabled_subtle has-disabled:text-fg-disabled_subtle",
"has-disabled:border-border-disabled has-disabled:bg-bg-disabled_subtle has-disabled:hover:bg-bg-disabled_subtle has-disabled:text-fg-disabled_subtle has-disabled:cursor-not-allowed",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The checkbox still presented itself as clickable even though it was disabled...

@danblackadder danblackadder changed the title Default account flow Default Account Flow - Continue Sep 30, 2025
let isEditAccountDialogVisible = $state<boolean>(false);
let isAuthorizing = $state(false);
let tooltipAnchorRef = $state<HTMLElement>();
let accountToEdit = $state<AccountInfo | undefined>(undefined);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Separated this from the isEditAccountDialogVisible as will be the same account we want to then delete if we press the "Delete account" button from within the edit dialog

@danblackadder danblackadder marked this pull request as ready for review September 30, 2025 16:17
type="button"
aria-labelledby={label ? "toggle" : undefined}
class={`bg-bg-tertiary relative flex h-5 w-9 flex-row items-center rounded-full p-0.5 ${toggled ? "justify-end" : "justify-start"}`}
onclick={() => onClick(!toggled)}
Copy link
Contributor

Choose a reason for hiding this comment

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

In Svelte, the native DOM onclick attribute should be replaced with Svelte's event directive syntax on:click. The Svelte syntax properly binds component methods and ensures proper event handling within the component lifecycle.

on:click={() => onClick(!toggled)}

This change applies to both button elements in this component that currently use onclick.

Suggested change
onclick={() => onClick(!toggled)}
on:click={() => onClick(!toggled)}

Spotted by Diamond

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

@aterga aterga requested a review from Copilot September 30, 2025 17:56
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements a default account flow for the authorization process with feature flag-controlled updates. The primary change introduces a simplified "Continue" button that uses a default account, replacing the previous multiple account selection approach.

  • Updated authorization flow to support default account selection with a single "Continue" button
  • Added toggle functionality to enable/disable multiple accounts view
  • Introduced account editing capabilities for renaming and setting default accounts

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
continue/+page.svelte Added default account flow with "Continue" button and multiple accounts toggle
account/+page.ts Added defaultAccount retrieval to page load function
account/+page.svelte Added account editing functionality and multiple accounts toggle
EditAccount.svelte New component for editing account names and default settings
CreateAccount.svelte Updated to support setting accounts as default during creation
Toggle.svelte New toggle component for multiple accounts feature
Checkbox.svelte Fixed disabled state styling to prevent hover effects

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +104 to +107
name: defaultAccount.name[0],
accountNumber: defaultAccount.account_number[0],
});
await authorizationStore.authorize(defaultAccount.account_number[0]);
Copy link
Preview

Copilot AI Sep 30, 2025

Choose a reason for hiding this comment

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

Potential undefined access when defaultAccount.name or defaultAccount.account_number arrays are empty. Consider adding null checks or providing fallback values.

Suggested change
name: defaultAccount.name[0],
accountNumber: defaultAccount.account_number[0],
});
await authorizationStore.authorize(defaultAccount.account_number[0]);
name: defaultAccount.name?.[0] ?? "",
accountNumber: defaultAccount.account_number?.[0] ?? "",
});
await authorizationStore.authorize(defaultAccount.account_number?.[0] ?? "");

Copilot uses AI. Check for mistakes.

)
.then(throwCanisterError);
}
accounts = [...accounts, account];
Copy link
Preview

Copilot AI Sep 30, 2025

Choose a reason for hiding this comment

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

This line adds the edited account to the accounts array instead of updating the existing account. This will create duplicate entries. Should update the existing account in the array instead.

Suggested change
accounts = [...accounts, account];
accounts = accounts.map((a) =>
JSON.stringify(a.account_number) === JSON.stringify(account.account_number) ? account : a
);

Copilot uses AI. Check for mistakes.

<label class="flex flex-row items-center gap-2">
<button
type="button"
aria-labelledby={label ? "toggle" : undefined}
Copy link
Preview

Copilot AI Sep 30, 2025

Choose a reason for hiding this comment

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

The aria-labelledby references 'toggle' but the actual id is 'toggle-label' (line 22). This will break accessibility as the label association won't work correctly.

Copilot uses AI. Check for mistakes.

<input
type="checkbox"
role="switch"
aria-labelledby={label ? "toggle" : undefined}
Copy link
Preview

Copilot AI Sep 30, 2025

Choose a reason for hiding this comment

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

The aria-labelledby references 'toggle' but the actual id is 'toggle-label' (line 22). This will break accessibility as the label association won't work correctly.

Copilot uses AI. Check for mistakes.

aria-labelledby={label ? "toggle" : undefined}
checked={toggled}
{disabled}
onchange={() => onClick(!toggled)}
Copy link
Preview

Copilot AI Sep 30, 2025

Choose a reason for hiding this comment

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

The hidden checkbox's onchange handler calls onClick(!toggled), but the button's onclick already does the same. This could cause the toggle to be called twice when using keyboard navigation, resulting in no state change.

Suggested change
onchange={() => onClick(!toggled)}

Copilot uses AI. Check for mistakes.

Copy link
Collaborator

@lmuntaner lmuntaner left a comment

Choose a reason for hiding this comment

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

Looking good to me!

Can you add some screenshots to better see the changes? Thanks!

<div class="size-4 rounded-full bg-white"></div>
</button>
{#if label}
<span id="toggle-label" class="text-text-secondary text-sm font-medium"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is the id needed?

<li class="contents">
<ButtonCard
onclick={() => handleContinueAs(account)}
onclick={() => handleContinueAs()}
Copy link
Collaborator

Choose a reason for hiding this comment

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

nitpick onclick={handleContinueAs}?

onclick={() => handleContinueAs(account)}
onclick={() => handleContinueAs()}
disabled={loading}
class="!justify-center"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do you need !justify-center?

),
);
let toggled = $state<boolean>(true);
Copy link
Collaborator

Choose a reason for hiding this comment

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

toggled what? Maybe toggledMultipleAccounts would be more descriptive?

try {
// TODO: fix account.account_number = []
// currently when requesting to update_account against a primary account
// as there is no account number is causes this to panic
Copy link
Collaborator

Choose a reason for hiding this comment

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

What panics? The backend?

)
.then(throwCanisterError);
if (isDefault) {
await $authenticatedStore.actor
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we do the requests in parallel?

variant="tertiary"
class="no-card-hover"
onclick={(event) => {
event.stopPropagation();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is event.stopPropagation(); needed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants