[PR #2287] [MERGED] fix: prevent cursor reset when typing in filter input #4037

Closed
opened 2026-03-22 14:59:17 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/go-vikunja/vikunja/pull/2287
Author: @kolaente
Created: 2/24/2026
Status: Merged
Merged: 2/24/2026
Merged by: @kolaente

Base: mainHead: fix-filter-input-cursor-reset


📝 Commits (3)

  • eee9202 test: add filter whitespace normalization tests
  • 5c13d86 fix: prevent cursor reset when typing in filter input
  • 35b59e1 fix: reset emission guard after applying external model updates

📊 Changes

2 files changed (+50 additions, -5 deletions)

View changed files

📝 frontend/src/components/input/filter/FilterInput.vue (+20 -5)
📝 frontend/src/helpers/filters.test.ts (+30 -0)

📄 Description

Summary

  • Track the last value emitted by the editor's onUpdate handler in FilterInput.vue. When the modelValue watch fires with a value matching the last emission, skip the setEditorContentFromModelValue call to avoid a destructive round-trip where transformFilterStringForApi normalizes whitespace (e.g., labels=flabels = f), causing setContent to replace the editor text and reset the cursor position.
  • Add regression tests documenting that transformFilterStringForApi normalizes spacing around operators.

Test plan

  • Type labels= followed by a search term — cursor stays at end, does not jump back
  • Type labels = (with spaces) followed by a search term — cursor stays at end
  • Type compound filters like done = false && labels = then a label name — cursor does not jump
  • Click a date value to open date picker — date picker still works correctly
  • Load an existing saved filter (e.g., labels = 42) — editor shows human-readable version
  • Unit tests pass: cd frontend && pnpm test:unit src/helpers/filters.test.ts

Fixes #2268


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/go-vikunja/vikunja/pull/2287 **Author:** [@kolaente](https://github.com/kolaente) **Created:** 2/24/2026 **Status:** ✅ Merged **Merged:** 2/24/2026 **Merged by:** [@kolaente](https://github.com/kolaente) **Base:** `main` ← **Head:** `fix-filter-input-cursor-reset` --- ### 📝 Commits (3) - [`eee9202`](https://github.com/go-vikunja/vikunja/commit/eee92026cced99b14e01c93fdd70aee762353147) test: add filter whitespace normalization tests - [`5c13d86`](https://github.com/go-vikunja/vikunja/commit/5c13d86b945abd347e6aa2dd0df862143e61db47) fix: prevent cursor reset when typing in filter input - [`35b59e1`](https://github.com/go-vikunja/vikunja/commit/35b59e12a273c2e39d69acb7ea7bccd4396ed792) fix: reset emission guard after applying external model updates ### 📊 Changes **2 files changed** (+50 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `frontend/src/components/input/filter/FilterInput.vue` (+20 -5) 📝 `frontend/src/helpers/filters.test.ts` (+30 -0) </details> ### 📄 Description ## Summary - Track the last value emitted by the editor's `onUpdate` handler in `FilterInput.vue`. When the `modelValue` watch fires with a value matching the last emission, skip the `setEditorContentFromModelValue` call to avoid a destructive round-trip where `transformFilterStringForApi` normalizes whitespace (e.g., `labels=f` → `labels = f`), causing `setContent` to replace the editor text and reset the cursor position. - Add regression tests documenting that `transformFilterStringForApi` normalizes spacing around operators. ## Test plan - [ ] Type `labels=` followed by a search term — cursor stays at end, does not jump back - [ ] Type `labels = ` (with spaces) followed by a search term — cursor stays at end - [ ] Type compound filters like `done = false && labels = ` then a label name — cursor does not jump - [ ] Click a date value to open date picker — date picker still works correctly - [ ] Load an existing saved filter (e.g., `labels = 42`) — editor shows human-readable version - [ ] Unit tests pass: `cd frontend && pnpm test:unit src/helpers/filters.test.ts` Fixes #2268 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-03-22 14:59:17 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/vikunja#4037