From 675a550247d4369da4fda7167a0799f03efeebde Mon Sep 17 00:00:00 2001 From: kolaente Date: Sun, 16 Nov 2025 15:38:24 +0100 Subject: [PATCH] fix(filter): restore cursor position when making changes Related https://github.com/go-vikunja/vikunja/issues/1395 --- frontend/src/components/input/filter/FilterInput.vue | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/frontend/src/components/input/filter/FilterInput.vue b/frontend/src/components/input/filter/FilterInput.vue index 4589eb651..876684661 100644 --- a/frontend/src/components/input/filter/FilterInput.vue +++ b/frontend/src/components/input/filter/FilterInput.vue @@ -154,9 +154,18 @@ function setEditorContentFromModelValue(newValue: string | undefined) { ) : '' if (editor.value.getText() !== content) { + // Preserve cursor position before updating content + const currentPosition = editor.value.state.selection.from + editor.value.commands.setContent(content, { emitUpdate: false, }) + + // Restore cursor position after content update + // Ensure position is within the new content bounds + const maxPosition = editor.value.state.doc.content.size + const safePosition = Math.min(currentPosition, maxPosition) + editor.value.commands.setTextSelection(safePosition) } }