Android task entry fix
This commit is contained in:
@ -24,6 +24,7 @@ export class TaskEditorModal extends Modal {
|
||||
private textarea: HTMLTextAreaElement | null = null;
|
||||
private selectedFile: TFile | null = null;
|
||||
private fileLabel: HTMLSpanElement | null = null;
|
||||
private keyboardHandler: (() => void) | null = null;
|
||||
|
||||
constructor(
|
||||
app: App,
|
||||
@ -45,6 +46,21 @@ export class TaskEditorModal extends Modal {
|
||||
const { contentEl } = this;
|
||||
contentEl.addClass('yaotp-editor-modal');
|
||||
|
||||
// On Android the on-screen keyboard shrinks the visual viewport but not
|
||||
// the layout viewport, so a fixed-position modal stays centered in the
|
||||
// full layout height and gets half-covered. We listen for visual-viewport
|
||||
// resize events and pull the modal container's bottom edge up to match,
|
||||
// keeping the modal in the visible area above the keyboard.
|
||||
if (window.visualViewport) {
|
||||
this.keyboardHandler = () => {
|
||||
const vv = window.visualViewport!;
|
||||
const keyboardHeight = Math.max(0, window.innerHeight - vv.height - vv.offsetTop);
|
||||
this.containerEl.style.bottom = `${keyboardHeight}px`;
|
||||
this.modalEl.style.maxHeight = keyboardHeight > 0 ? `${vv.height * 0.9}px` : '';
|
||||
};
|
||||
window.visualViewport.addEventListener('resize', this.keyboardHandler);
|
||||
}
|
||||
|
||||
// Title
|
||||
contentEl.createEl('h2', { text: 'Edit task' });
|
||||
|
||||
@ -111,6 +127,10 @@ export class TaskEditorModal extends Modal {
|
||||
}
|
||||
|
||||
onClose(): void {
|
||||
if (this.keyboardHandler) {
|
||||
window.visualViewport?.removeEventListener('resize', this.keyboardHandler);
|
||||
this.keyboardHandler = null;
|
||||
}
|
||||
this.contentEl.empty();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user