[PR #1996] [MERGED] fix(filters): ensure saved filter views never have position=0 #7980

Closed
opened 2026-04-20 17:57:55 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/go-vikunja/vikunja/pull/1996
Author: @kolaente
Created: 12/16/2025
Status: Merged
Merged: 12/16/2025
Merged by: @kolaente

Base: mainHead: fix-filter-position


📝 Commits (3)

  • a3fa166 fix(filters): ensure saved filter views never have position=0
  • 844b65f refactor(tests): use xorm Count instead of Find for count checks
  • 70b8ff3 refactor: use GetSavedFilterIDFromProjectID helper for filter detection

📊 Changes

4 files changed (+287 additions, -19 deletions)

View changed files

📝 pkg/models/saved_filter_positions_test.go (+213 -0)
📝 pkg/models/saved_filters.go (+5 -19)
📝 pkg/models/task_position.go (+40 -0)
📝 pkg/models/tasks.go (+29 -0)

📄 Description

Summary

Fixes #724 - Tasks in saved filter views get position: 0 when they first appear in the filter, causing drag-and-drop sorting to not persist correctly.

Changes:

  • Remove harmful Position: 0 inserts from cron job and SavedFilter.Update - RecalculateTaskPositions already creates positions with proper values, so the intermediate inserts created a race window
  • Add on-demand position creation when fetching tasks for saved filter views - safety net for newly matching tasks before the cron runs
  • Add 5 new tests covering the fix and regression scenarios

Test Plan

  • All existing saved filter and position tests pass
  • All models tests pass
  • Manual verification: Create a saved filter with done = false, create tasks in Inbox, open the filter view, verify all tasks have position > 0 in network trace
  • Manual verification: Drag a task to reorder, refresh page, verify order persists

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Improved task position consistency in saved filter views, ensuring tasks maintain proper ordering in filtered kanban views
    • Fixed sorting stability on filtered views by ensuring all tasks receive proper position assignments
  • Tests

    • Added comprehensive test coverage for saved filter position logic and edge cases

✏️ Tip: You can customize this high-level summary in your review settings.


🔄 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/1996 **Author:** [@kolaente](https://github.com/kolaente) **Created:** 12/16/2025 **Status:** ✅ Merged **Merged:** 12/16/2025 **Merged by:** [@kolaente](https://github.com/kolaente) **Base:** `main` ← **Head:** `fix-filter-position` --- ### 📝 Commits (3) - [`a3fa166`](https://github.com/go-vikunja/vikunja/commit/a3fa166a9056c44a0aa201ee08bd7d401fe6134f) fix(filters): ensure saved filter views never have position=0 - [`844b65f`](https://github.com/go-vikunja/vikunja/commit/844b65f9909fea288f7c5b6471ab434f0ee779b4) refactor(tests): use xorm Count instead of Find for count checks - [`70b8ff3`](https://github.com/go-vikunja/vikunja/commit/70b8ff3d92f94deafb5c3fad3e609edd70fc5955) refactor: use GetSavedFilterIDFromProjectID helper for filter detection ### 📊 Changes **4 files changed** (+287 additions, -19 deletions) <details> <summary>View changed files</summary> 📝 `pkg/models/saved_filter_positions_test.go` (+213 -0) 📝 `pkg/models/saved_filters.go` (+5 -19) 📝 `pkg/models/task_position.go` (+40 -0) 📝 `pkg/models/tasks.go` (+29 -0) </details> ### 📄 Description ## Summary Fixes #724 - Tasks in saved filter views get `position: 0` when they first appear in the filter, causing drag-and-drop sorting to not persist correctly. **Changes:** - Remove harmful `Position: 0` inserts from cron job and `SavedFilter.Update` - `RecalculateTaskPositions` already creates positions with proper values, so the intermediate inserts created a race window - Add on-demand position creation when fetching tasks for saved filter views - safety net for newly matching tasks before the cron runs - Add 5 new tests covering the fix and regression scenarios ## Test Plan - [x] All existing saved filter and position tests pass - [x] All models tests pass - [ ] Manual verification: Create a saved filter with `done = false`, create tasks in Inbox, open the filter view, verify all tasks have `position > 0` in network trace - [ ] Manual verification: Drag a task to reorder, refresh page, verify order persists <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes * **Bug Fixes** * Improved task position consistency in saved filter views, ensuring tasks maintain proper ordering in filtered kanban views * Fixed sorting stability on filtered views by ensuring all tasks receive proper position assignments * **Tests** * Added comprehensive test coverage for saved filter position logic and edge cases <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <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-04-20 17:57:55 -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#7980