mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-08-02 12:32:14 +00:00
feat(tasks): focus sub task on creation
This commit is contained in:
parent
c841a85e83
commit
a5fefa4ae9
1 changed files with 12 additions and 2 deletions
|
|
@ -111,7 +111,6 @@ export class TaskComponent implements OnInit, OnDestroy, AfterViewInit {
|
|||
.subscribe((id) => {
|
||||
this.isCurrent = (this.task && id === this.task.id);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
ngAfterViewInit() {
|
||||
|
|
@ -126,6 +125,13 @@ export class TaskComponent implements OnInit, OnDestroy, AfterViewInit {
|
|||
this.focusSelfElement();
|
||||
}
|
||||
});
|
||||
|
||||
// hacky but relatively performant
|
||||
if (this.task.parentId && Date.now() - 100 < this.task.created) {
|
||||
setTimeout(() => {
|
||||
this.focusTitleForEdit();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
|
|
@ -219,6 +225,10 @@ export class TaskComponent implements OnInit, OnDestroy, AfterViewInit {
|
|||
this._elementRef.nativeElement.focus();
|
||||
}
|
||||
|
||||
focusTitleForEdit() {
|
||||
this.editOnClickEl.nativeElement.focus();
|
||||
}
|
||||
|
||||
|
||||
onTaskAdditionalInfoOpenChanged($event) {
|
||||
this._taskService.update(this.task.id, {notes: $event.newVal});
|
||||
|
|
@ -234,7 +244,7 @@ export class TaskComponent implements OnInit, OnDestroy, AfterViewInit {
|
|||
const isShiftOrCtrlPressed = (ev.shiftKey === true || ev.ctrlKey === true);
|
||||
|
||||
if (checkKeyCombo(ev, keys.taskEditTitle) || ev.key === 'Enter') {
|
||||
this.editOnClickEl.nativeElement.focus();
|
||||
this.focusTitleForEdit();
|
||||
// prevent blur
|
||||
ev.preventDefault();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue