From 0f0b48eda4d0435042b38bda72635b46c366c532 Mon Sep 17 00:00:00 2001 From: claire bontempo <68122737+hellobontempo@users.noreply.github.com> Date: Thu, 12 Jan 2023 13:03:22 -0800 Subject: [PATCH] ui: unload auth method when navigating away from form (#18651) * unload record instead of rollback * unload record instead of rollback * add changelog * add rollback attrs back if record is not new --- changelog/18651.txt | 3 +++ ui/app/components/mount-backend-form.js | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 changelog/18651.txt diff --git a/changelog/18651.txt b/changelog/18651.txt new file mode 100644 index 000000000..9fc7ff8e4 --- /dev/null +++ b/changelog/18651.txt @@ -0,0 +1,3 @@ +```release-note:bug +ui: cleanup unsaved auth method ember data record when navigating away from mount backend form +``` \ No newline at end of file diff --git a/ui/app/components/mount-backend-form.js b/ui/app/components/mount-backend-form.js index fafd5a4a6..4cb9c33d5 100644 --- a/ui/app/components/mount-backend-form.js +++ b/ui/app/components/mount-backend-form.js @@ -33,7 +33,10 @@ export default class MountBackendForm extends Component { willDestroy() { // if unsaved, we want to unload so it doesn't show up in the auth mount list super.willDestroy(...arguments); - this.args.mountModel.rollbackAttributes(); + if (this.args.mountModel) { + const method = this.args.mountModel.isNew ? 'unloadRecord' : 'rollbackAttributes'; + this.args.mountModel[method](); + } } checkPathChange(type) {