Ignore page direction buttons
Fix pushing page from view by PageUp
This commit is contained in:
parent
03b0e602e3
commit
904f9df459
@ -747,6 +747,21 @@ export default class ChatInput {
|
||||
this.sendMessage();
|
||||
} else if(e.ctrlKey || e.metaKey) {
|
||||
this.handleMarkdownShortcut(e);
|
||||
} else if((e.key === 'PageUp' || e.key === 'PageDown') && !e.shiftKey) { // * fix pushing page to left (Chrome Windows)
|
||||
e.preventDefault();
|
||||
|
||||
if(e.key === 'PageUp') {
|
||||
const range = document.createRange();
|
||||
const sel = window.getSelection();
|
||||
|
||||
range.setStart(this.messageInput.childNodes[0] || this.messageInput, 0);
|
||||
range.collapse(true);
|
||||
|
||||
sel.removeAllRanges();
|
||||
sel.addRange(range);
|
||||
} else {
|
||||
placeCaretAtEnd(this.messageInput);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -429,8 +429,9 @@ export class AppImManager {
|
||||
private init() {
|
||||
document.addEventListener('paste', this.onDocumentPaste, true);
|
||||
|
||||
const IGNORE_KEYS = new Set(['PageUp', 'PageDown', 'Meta', 'Control']);
|
||||
const onKeyDown = (e: KeyboardEvent) => {
|
||||
if(rootScope.overlayIsActive) return;
|
||||
if(rootScope.overlayIsActive || IGNORE_KEYS.has(e.key)) return;
|
||||
|
||||
const target = e.target as HTMLElement;
|
||||
|
||||
@ -440,9 +441,7 @@ export class AppImManager {
|
||||
|
||||
const chat = this.chat;
|
||||
|
||||
if(e.key === 'Meta' || e.key === 'Control') {
|
||||
return;
|
||||
} else if(e.code === "KeyC" && (e.ctrlKey || e.metaKey) && target.tagName !== 'INPUT') {
|
||||
if(e.code === 'KeyC' && (e.ctrlKey || e.metaKey) && target.tagName !== 'INPUT') {
|
||||
return;
|
||||
} else if(e.code === 'ArrowUp') {
|
||||
if(!chat.input.editMsgId && chat.input.isInputEmpty()) {
|
||||
@ -469,10 +468,18 @@ export class AppImManager {
|
||||
cancelEvent(e); // * prevent from scrolling
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
} else if(e.code === 'ArrowDown') {
|
||||
return;
|
||||
}
|
||||
|
||||
if(chat.input.messageInput && e.target !== chat.input.messageInput && target.tagName !== 'INPUT' && !target.hasAttribute('contenteditable') && !isTouchSupported) {
|
||||
if(chat.input.messageInput &&
|
||||
e.target !== chat.input.messageInput &&
|
||||
target.tagName !== 'INPUT' &&
|
||||
!target.hasAttribute('contenteditable') &&
|
||||
!isTouchSupported) {
|
||||
chat.input.messageInput.focus();
|
||||
placeCaretAtEnd(chat.input.messageInput);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user