Skip to content

fix(fxa-settings): Fix gql loading issues and set password not keeping state#20059

Merged
vbudhram merged 1 commit intomainfrom
gql-fixes
Feb 17, 2026
Merged

fix(fxa-settings): Fix gql loading issues and set password not keeping state#20059
vbudhram merged 1 commit intomainfrom
gql-fixes

Conversation

@vbudhram
Copy link
Copy Markdown
Contributor

@vbudhram vbudhram commented Feb 13, 2026

Because

  • You might see a flash of default state before the account loads in settings
  • We didn't update local cache after setting a password

This pull request

  • Adds a loading indicator to wait for account state to get loaded before showing setting
  • Updates account local storage state after setting password

Issue that this pull request solves

Closes: https://mozilla-hub.atlassian.net/browse/FXA-13107
Closes: https://mozilla-hub.atlassian.net/browse/FXA-13109

Checklist

  • My commit is GPG signed.
  • If applicable, I have modified or added tests which pass locally.
  • I have added necessary documentation (if appropriate).
  • I have verified that my changes render correctly in RTL (if appropriate).

Other information (Optional)

Its kinda hard to reproduce settings refresh issue locally (I wasn't actually able too), but this seems to be reasonable to me what might be going on.

@vbudhram vbudhram requested a review from a team as a code owner February 13, 2026 20:50
@vbudhram vbudhram self-assigned this Feb 13, 2026
@dschom dschom self-requested a review February 14, 2026 00:28
Copilot AI review requested due to automatic review settings February 15, 2026 15:32
Copy link
Copy Markdown

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 fixes two issues in the FXA settings application: a flash of default state before account loads, and the hasPassword field not being updated in local cache after setting a password.

Changes:

  • Modified useAccountData hook to use local React state for loading/error instead of persisting to global AccountState context, preventing the flash of default state on page reload
  • Updated createPassword and createPasswordWithJwt methods to set hasPassword: true in the account state after creating a password
  • Refactored useAccountData to use refs for authClient to prevent unnecessary re-renders and dependency issues

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/fxa-settings/src/models/Account.ts Added hasPassword: true to state updates in createPassword and createPasswordWithJwt methods
packages/fxa-settings/src/lib/hooks/useAccountData.ts Refactored to use local state for loading/error, added authClient ref, updated dependency arrays, and removed trailing whitespace

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


const accountState = useAccountState();
const {
setAccountData,
Copy link

Copilot AI Feb 15, 2026

Choose a reason for hiding this comment

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

The destructuring here only removes setAccountData from accountState, but accountState also contains other action functions like updateField, setLoading, setFieldLoading, setError, and clearAccount from the AccountStateActions interface. These action functions will be included in stateData and then spread into the returned data object (line 306), even though the return type AccountState doesn't include them.

Consider destructuring all action functions to keep only the state data, similar to how the old code explicitly removed setLoading and setError. For example:

const {
  setAccountData,
  updateField,
  setLoading,
  setFieldLoading,
  setError,
  clearAccount,
  ...stateData
} = accountState;

This would improve type safety and make the code more explicit about what's being included in the returned data.

Suggested change
setAccountData,
setAccountData,
updateField,
setLoading,
setFieldLoading,
setError,
clearAccount,

Copilot uses AI. Check for mistakes.
@vbudhram vbudhram force-pushed the gql-fixes branch 2 times, most recently from 0cf4e6c to 0d5bcaa Compare February 15, 2026 18:50
…sword and fix loading state flash

After creating a password via createPassword/createPasswordWithJwt, localStorage
was not updated with hasPassword: true, causing the app to still show the
"set password" flow and resulting in errno 206 on retry.

The loading/error state in useAccountData was routed through localStorage where
transient fields are stripped, so isLoading was always false. This caused a flash
of default values (security features shown as disabled) before the data fetch
completed. Switched to local React state for loading/error tracking.
Copy link
Copy Markdown
Contributor

@nshirley nshirley left a comment

Choose a reason for hiding this comment

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

I was able to test locally and it appears to be working - no delay to show the password field when adding one after unlinking a 3rd party auth account

@vbudhram vbudhram merged commit 898f8cc into main Feb 17, 2026
22 checks passed
@vbudhram vbudhram deleted the gql-fixes branch February 17, 2026 20:15
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.

3 participants