fix(filter): restore cursor position when making changes
Related https://github.com/go-vikunja/vikunja/issues/1395
This commit is contained in:
parent
2e3b2cb770
commit
675a550247
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue