-
Notifications
You must be signed in to change notification settings - Fork 157
Default Account Flow - Continue #3384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
"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", |
There was a problem hiding this comment.
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...
let isEditAccountDialogVisible = $state<boolean>(false); | ||
let isAuthorizing = $state(false); | ||
let tooltipAnchorRef = $state<HTMLElement>(); | ||
let accountToEdit = $state<AccountInfo | undefined>(undefined); |
There was a problem hiding this comment.
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
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)} |
There was a problem hiding this comment.
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
.
onclick={() => onClick(!toggled)} | |
on:click={() => onClick(!toggled)} |
Spotted by Diamond
Is this helpful? React 👍 or 👎 to let us know.
There was a problem hiding this 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.
name: defaultAccount.name[0], | ||
accountNumber: defaultAccount.account_number[0], | ||
}); | ||
await authorizationStore.authorize(defaultAccount.account_number[0]); |
There was a problem hiding this comment.
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.
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]; |
There was a problem hiding this comment.
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.
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} |
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
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)} |
There was a problem hiding this comment.
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.
onchange={() => onClick(!toggled)} |
Copilot uses AI. Check for mistakes.
There was a problem hiding this 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" |
There was a problem hiding this comment.
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()} |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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?
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
Toggle.Svelte
create
withinCreateAccount.svelte
to handle a default optionEditAccount.svelte
view which is currently hidden behind the feature flageditAccount
toaccounts
routedefaultAccount
added toaccount/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