Skip to content

Stop Account Name and Username refilling after they are cleared - #452

Open
Gabriel-Dalton wants to merge 1 commit into
hkdb:v0.3.6-devfrom
Gabriel-Dalton:fix/account-name-autofill-refill
Open

Gabriel-Dalton wants to merge 1 commit into
hkdb:v0.3.6-devfrom
Gabriel-Dalton:fix/account-name-autofill-refill

Conversation

@Gabriel-Dalton

Copy link
Copy Markdown

Fixes #451.

Problem

In Add Account, clearing Account Name (or Username) makes it fill itself straight back in, so the field cannot be emptied or retyped from scratch.

The auto-fill $effect in AccountForm.svelte reads name and username to check whether they are empty. In Svelte 5 that makes them dependencies of the effect, so clearing either one re-runs it and it refills the field.

Change

  • Read name, username and prevEmail with untrack, so editing those fields never re-runs the auto-fill. It still runs when the email changes.
  • Track the name the form filled in (prevAutoName) and only overwrite a name that is empty or still equal to it. A name the user typed is never replaced.

Side effect: the name now follows the email while it is being typed. Before, typing the address one character at a time left the name stuck at the first letter, because the field was no longer empty after the first keystroke.

Edit mode is unaffected: the loaded account name differs from prevAutoName, so it is kept.

Checks

  • svelte-check: 0 errors, 0 warnings
  • eslint on the file: clean
  • wails build on Windows 11: builds

The auto-fill effect read name and username to check whether they were empty, which made them dependencies of the effect. Clearing either field re-ran the effect and filled it straight back in, so the field could not be emptied or retyped from scratch. Read them untracked, and only overwrite a name the form filled in itself. As a side effect the name now follows the email while it is typed, instead of sticking at the first letter.
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.

1 participant