StoicBuilder
Later missionMission 5: Cancel that didn't cancelYou can practise it now. It counts once you reach mission 5, after “Twenty dollars on the dot”.Back to HQ

DrillsCancel didn't undo my edit

Cancel didn't undo my edit

I the LudusGuildhall, built with LovableSteadyAbout 5 minPro

What happened

Guildhall's Edit profile dialog has Save and Cancel. You changed your bio, mistyped your website, and pressed Cancel to throw it all away. The dialog closed, and your profile page shows the new bio and the typo anyway.

A guild memberI pressed Cancel because I'd made a typo. The typo is on my profile now.
What you seeOn screen
Profile page: Bookbinder in Lisbon. Commissions open for January. | anareyes.ptt

The MagisterRun it first and read what comes back. Then change the code if you like: your edits go to the review too.

Run it: the last line prints what the profile page shows after Cancel.

// Edit profile: changes go into a draft. Save keeps them, Cancel throws the draft away.
let savedProfile = {
  name: "Ana Reyes",
  bio: "Bookbinder in Lisbon.",
  links: { website: "anareyes.pt", instagram: "@ana.binds" },
};

function startEditing() {
  const draft = savedProfile;
  return draft;
}

function save(draft) {
  savedProfile = draft;
}

// You open the dialog, change two things, then press Cancel (save is never called).
const draft = startEditing();
draft.bio = "Bookbinder in Lisbon. Commissions open for January.";
draft.links.website = "anareyes.ptt";

console.log(`Profile page: ${savedProfile.bio} | ${savedProfile.links.website}`);

The code runs in your browser against stand-in data. Nothing is sent anywhere.

Your answer

Reviewed by AI against what a good fix needs. About 10 seconds.

Sign in to get your answer reviewed

It's free. Anything you've typed here stays in this browser and is waiting when you come back.

Sign in with email