Android task entry fix

This commit is contained in:
2026-03-29 11:00:41 -04:00
parent 596a27c952
commit 2475204000
2 changed files with 36 additions and 1 deletions

17
main.js

File diff suppressed because one or more lines are too long

View File

@ -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();
}