Skip to content

fix(profile): prevent saving profile when no changes are made (@AzureNightlock)#7684

Open
AzureNightlock wants to merge 2 commits intomonkeytypegame:masterfrom
AzureNightlock:fix/profile-save-without-changes
Open

fix(profile): prevent saving profile when no changes are made (@AzureNightlock)#7684
AzureNightlock wants to merge 2 commits intomonkeytypegame:masterfrom
AzureNightlock:fix/profile-save-without-changes

Conversation

@AzureNightlock
Copy link
Contributor

Description

This PR: Fixes edit-profile.ts so the profile is not submitted again when the user clicks Save without making any changes.

To support that behavior, this PR:

  • Introduces a profile state shape used to capture form values.
  • Stores the original profile state when the modal is opened.
  • Reads the current profile state at save time.
  • Compares the original and current profile states before submitting.
  • Prevents the save request when no changes are detected.
  • Shows a "No changes to save" notification when the profile is unchanged.
  • Reuses getProfileState() to avoid reading form inputs twice.
  • Renames buildUpdatesFromInputs to buildUpdatesFromState for clarity, since updates are now built from the captured form state instead of reading inputs again.

Additional small fixes:

  • Adds a guard in initializeCharacterCounters to avoid attaching duplicate listeners.
  • Handles the case where inventory exists but badges is undefined.
  • Corrects a typo in a comment.
  • Changes the checkbox cursor to pointer.

Checks

  • Check if any open issues are related to this PR; if so, be sure to tag them below.
  • Make sure the PR title follows the Conventional Commits standard. (https://www.conventionalcommits.org for more info)
  • Make sure to include your GitHub username prefixed with @ inside parentheses at the end of the PR title.

Closes #7683

@monkeytypegeorge monkeytypegeorge added the frontend User interface or web stuff label Mar 19, 2026
@AzureNightlock
Copy link
Contributor Author

AzureNightlock commented Mar 19, 2026

Testing note: I created an edit-profile-spec test, and it passed locally. I wasn't able to fully verify this change visually because there isn't a Story for this section, and I wasn't able to set up the backend properly. So the validation for this change was based on the spec test and the updated no-change save logic.

Also for future fixes in account-related areas like this, is there a recommended way to test them visually/locally end-to-end? I've run into this issue a few times and would love to be able to test these fixes better.


snapshot.details = response.body.data ?? updates;
snapshot.inventory?.badges.forEach((badge) => {
snapshot.inventory?.badges?.forEach((badge) => {
Copy link
Contributor

@Leonabcd123 Leonabcd123 Mar 19, 2026

Choose a reason for hiding this comment

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

Why is this necessary? I don't think badges can be undefined/null.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing that out! I added it defensively but the extra optional chaining on badges was unnecessary. Sorry for that oversight and I appreciate the careful review!

@fehmer
Copy link
Member

fehmer commented Mar 19, 2026

hi @AzureNightlock , thank you for your contribution.

The best call would be to get the backend working on your machine. Can you join discord so we can trouble shoot your problem?

Let us know what other changes you have planned that are account-related. We are currently migrating the frontend to use solid-js and I think we can get this fix "for free" with the new stack.

@AzureNightlock
Copy link
Contributor Author

Sure I would love to! I have already joined the Discord already and I do have a few other account-related bugs in mind that I was thinking of looking into as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend User interface or web stuff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Profile saves even when no changes are made

4 participants