Skip to content

Commit

Permalink
Merge pull request #453 from lblod/bugfix/problem-with-title-in-dev
Browse files Browse the repository at this point in the history
Bugfix/problem with title in dev
  • Loading branch information
lagartoverde authored Apr 21, 2023
2 parents 09f8d7b + 5fece01 commit 91785d9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/components/editor-document-title.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
{{else}}
<h1 class="au-c-app-chrome__title au-c-app-chrome__title--edit" title={{this.title}}>
{{limit-content this.title 70}}
<AuButton {{on "click" this.toggleActive}} @icon="pencil" @skin="tertiary" @hideText={{true}} >{{t "editor-document-title.change-title"}}</AuButton>
<AuButton {{on "click" this.enableEdit}} @icon="pencil" @skin="tertiary" @hideText={{true}} >{{t "editor-document-title.change-title"}}</AuButton>
</h1>
{{#if this.showSaved}}
<AuPill
Expand Down
23 changes: 18 additions & 5 deletions app/components/editor-document-title.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default class EditorDocumentTitleComponent extends Component {
submit(event) {
event.preventDefault();
this.args.onSubmit?.(this.title);
this.toggleActive();
this.disabledEdit();
this.showSaved = true;
setTimeout(() => (this.showSaved = false), 30000);
return false;
Expand All @@ -51,16 +51,29 @@ export default class EditorDocumentTitleComponent extends Component {
cancel(event) {
if (!event.currentTarget.contains(event.relatedTarget)) {
this._title = undefined;
this.toggleActive();
this.disabledEdit();
}
}

// We check the value of active in these 2 functions to avoid setting it 2 times in the same computation with
// the cancel event + submit which cause a bug in prod environments.
@action
toggleActive() {
if (this.active && !this.title) {
enableEdit() {
if (this.active) {
return;
}
this.active = true;
}

@action
disabledEdit() {
if (!this.active) {
return;
}
if (!this.title) {
this.error = true;
} else {
this.active = !this.active;
this.active = false;
}
}

Expand Down

0 comments on commit 91785d9

Please sign in to comment.