diff --git a/src/accounting/static/js/description-editor.js b/src/accounting/static/js/description-editor.js index fdc99be..2340f8c 100644 --- a/src/accounting/static/js/description-editor.js +++ b/src/accounting/static/js/description-editor.js @@ -199,6 +199,7 @@ class DescriptionEditor { * */ #onDescriptionChange() { + this.#reset(); this.description = this.description.trim(); for (const tabPlane of [this.tabPlanes.recurring, this.tabPlanes.bus, this.tabPlanes.travel, this.tabPlanes.general]) { if (tabPlane.populate()) { @@ -208,6 +209,17 @@ class DescriptionEditor { this.tabPlanes.annotation.populate(); } + /** + * Resets the description editor. + * + */ + #reset() { + for (const tabPlane of Object.values(this.tabPlanes)) { + tabPlane.reset(); + } + this.tabPlanes.general.switchToMe(); + } + /** * Updates the current suggested accounts. * @@ -289,10 +301,9 @@ class DescriptionEditor { * */ onOpen() { - this.#reset(); - this.#setConfirmedAccount(); this.description = this.lineItemEditor.description === null? "": this.lineItemEditor.description; this.#onDescriptionChange(); + this.#setConfirmedAccount(); } /** @@ -311,18 +322,6 @@ class DescriptionEditor { this.selectAccount(this.#confirmedAccount); } - /** - * Resets the description editor. - * - */ - #reset() { - this.description = ""; - for (const tabPlane of Object.values(this.tabPlanes)) { - tabPlane.reset(); - } - this.tabPlanes.general.switchToMe(); - } - /** * Returns the description editor instances. *