Skip to content

Commit

Permalink
fix(newTitleEdit): not being able to edit current task properly
Browse files Browse the repository at this point in the history
  • Loading branch information
johannesjo committed Jul 29, 2024
1 parent 9170959 commit 4cef14d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
class="task-title-wrapper"
>
<inline-multiline-input
[resetToInitialValueTrigger]="task"
[resetToLastExternalValueTrigger]="task"
(valueEdited)="updateTaskTitleIfChanged($event.wasChanged, $event.newVal)"
[value]="task.title"
class="task-title"
Expand Down
2 changes: 1 addition & 1 deletion src/app/features/tasks/task/task.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
</div>

<inline-multiline-input
[resetToInitialValueTrigger]="task"
[resetToLastExternalValueTrigger]="task"
[style.pointer-events]="IS_TOUCH_PRIMARY && (task.title.length) ? 'none' : 'auto'"
#taskTitleEditEl
(valueEdited)="updateTaskTitleIfChanged($event)"
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/schedule-page/schedule-page.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ <h2>{{T.SCHEDULE.SCHEDULED_TASKS|translate}}</h2>
<div class="task-info">
<div class="title">
<inline-multiline-input
[resetToInitialValueTrigger]="task"
[resetToLastExternalValueTrigger]="task"
(valueEdited)="updateTaskTitleIfChanged($event.wasChanged, $event.newVal, task)"
[value]="task.title"
class="task-title"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,27 @@ export class InlineMultilineInputComponent {
@HostBinding('class.is-focused') isFocused = false;

// NOTE: we only need this for tasks since, sometimes with the short syntax there are no changes to the title as they are stripped away
@Input() set resetToInitialValueTrigger(value: unknown) {
this.tmpValue = this.initialValue;
@Input() set resetToLastExternalValueTrigger(value: unknown) {
// console.log({
// tmp: this.tmpValue,
// last: this.lastExternalValue,
// });
// never update while editing
if (!this.isFocused && this.tmpValue !== this.lastExternalValue) {
// NOTE: this works because set value is called after this, for non-short syntax only changes
this.tmpValue = this.lastExternalValue;
console.log('new tmp', this.tmpValue);
}
}

@Input() set value(value: string) {
this.tmpValue = value;
this.initialValue = value;
this.lastExternalValue = value;
this._setTxtHeight();
console.log(value);
// console.log('setValue', value);
}

initialValue?: string;
lastExternalValue?: string;
tmpValue?: string;

@ViewChild('textAreaElement') textarea!: ElementRef<HTMLTextAreaElement>;
Expand Down Expand Up @@ -123,9 +132,15 @@ export class InlineMultilineInputComponent {
const cleanVal = this._cleanValue(this.tmpValue);
this.valueEdited.emit({
newVal: cleanVal,
wasChanged: cleanVal !== this.initialValue,
wasChanged: cleanVal !== this.lastExternalValue,
});
this.tmpValue = cleanVal;
// console.log(
// 'submit',
// this.tmpValue,
// 'wasChanged',
// cleanVal !== this.lastExternalValue,
// );

// android needs the delay for the linebreaks to be removed
setTimeout(() => {
this._setTxtHeight();
Expand Down

0 comments on commit 4cef14d

Please sign in to comment.