fix: do not lose focus when switching channels, only trigger focus changes if a message was removed with the delete key
This commit is contained in:
@@ -44,14 +44,13 @@ export class List extends UINode {
|
|||||||
if (idx === this.focused) {
|
if (idx === this.focused) {
|
||||||
if (this.focused > 0) this.focused--;
|
if (this.focused > 0) this.focused--;
|
||||||
this.calculateTabIndex();
|
this.calculateTabIndex();
|
||||||
this.children[this.focused].focus()
|
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public _onFocus() {
|
public _onFocus() {
|
||||||
super._onFocus();
|
super._onFocus();
|
||||||
this.children[this.focused].focus();
|
this.focusSelectedMessage();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,14 +74,14 @@ export class List extends UINode {
|
|||||||
this.children[this.focused].setTabbable(false);
|
this.children[this.focused].setTabbable(false);
|
||||||
this.focused = Math.max(0, this.focused - 1);
|
this.focused = Math.max(0, this.focused - 1);
|
||||||
this.children[this.focused].setTabbable(true);
|
this.children[this.focused].setTabbable(true);
|
||||||
this.children[this.focused].focus();
|
this.focusSelectedMessage();
|
||||||
return true;
|
return true;
|
||||||
break;
|
break;
|
||||||
case "ArrowDown":
|
case "ArrowDown":
|
||||||
this.children[this.focused].setTabbable(false);
|
this.children[this.focused].setTabbable(false);
|
||||||
this.focused = Math.min(this.children.length - 1, this.focused + 1);
|
this.focused = Math.min(this.children.length - 1, this.focused + 1);
|
||||||
this.children[this.focused].setTabbable(true);
|
this.children[this.focused].setTabbable(true);
|
||||||
this.children[this.focused].focus();
|
this.focusSelectedMessage();
|
||||||
return true;
|
return true;
|
||||||
break;
|
break;
|
||||||
case "Enter":
|
case "Enter":
|
||||||
@@ -93,14 +92,14 @@ export class List extends UINode {
|
|||||||
this.children[this.focused].setTabbable(false);
|
this.children[this.focused].setTabbable(false);
|
||||||
this.focused = 0;
|
this.focused = 0;
|
||||||
this.children[this.focused].setTabbable(true);
|
this.children[this.focused].setTabbable(true);
|
||||||
this.children[this.focused].focus();
|
this.focusSelectedMessage();
|
||||||
return true;
|
return true;
|
||||||
break;
|
break;
|
||||||
case "End":
|
case "End":
|
||||||
this.children[this.focused].setTabbable(false);
|
this.children[this.focused].setTabbable(false);
|
||||||
this.focused = this.children.length - 1;
|
this.focused = this.children.length - 1;
|
||||||
this.children[this.focused].setTabbable(true);
|
this.children[this.focused].setTabbable(true);
|
||||||
this.children[this.focused].focus();
|
this.focusSelectedMessage();
|
||||||
return true;
|
return true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -169,4 +168,8 @@ export class List extends UINode {
|
|||||||
this.children[this.focused].setTabbable(true);
|
this.children[this.focused].setTabbable(true);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public focusSelectedMessage() {
|
||||||
|
this.children[this.focused].focus()
|
||||||
|
}
|
||||||
}
|
}
|
@@ -228,11 +228,13 @@ export class MainView extends View {
|
|||||||
itm.onClick(() => {
|
itm.onClick(() => {
|
||||||
this.openMessageDialog(message);
|
this.openMessageDialog(message);
|
||||||
})
|
})
|
||||||
itm.onKeyDown((key: string, alt: boolean | undefined, shift: boolean | undefined, ctrl: boolean | undefined) => {
|
itm.onKeyDown(async(key: string, alt: boolean | undefined, shift: boolean | undefined, ctrl: boolean | undefined) => {
|
||||||
if (key === "Delete") {
|
if (key === "Delete") {
|
||||||
this.removeMessage(message.id);
|
await this.removeMessage(message.id);
|
||||||
if (this.messageList.children.length === 1) {
|
if (this.messageList.children.length === 0) {
|
||||||
this.messageInput.focus()
|
this.messageInput.focus()
|
||||||
|
} else {
|
||||||
|
this.messageList.focusSelectedMessage()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user