fix: prevent Enter key from re-running a settled search #479

Merged
guettlibot merged 5 commits from issue-473-search-result-reorder into main 2026-06-07 02:38:31 +00:00
guettlibot commented 2026-06-06 14:38:08 +00:00 (Migrated from codeberg.org)

Summary

  • When a user typed a query, onChanged already ran _runSearch and results settled. Pressing Enter then triggered onSubmitted, firing a second IMAP search whose response could arrive in a different order — silently reordering the visible list so the tile at position 0 no longer corresponded to the email the user tapped.
  • Fixed by guarding onSubmitted: it now skips _runSearch when results are already present (_searchResults != null) or a search is already in flight (_searchLoading).
  • Added a regression test that verifies list order is unchanged after pressing Enter on an already-settled search.

Closes #473

Test plan

  • flutter test test/widget/email_list_screen_test.dart — all 24 tests pass, including the new "pressing Enter after search settles does not reorder results"
  • Manually: type a query in folder view search, wait for results to settle, press Enter — list order must not change

🤖 Generated with Claude Code

## Summary - When a user typed a query, `onChanged` already ran `_runSearch` and results settled. Pressing Enter then triggered `onSubmitted`, firing a second IMAP search whose response could arrive in a different order — silently reordering the visible list so the tile at position 0 no longer corresponded to the email the user tapped. - Fixed by guarding `onSubmitted`: it now skips `_runSearch` when results are already present (`_searchResults != null`) or a search is already in flight (`_searchLoading`). - Added a regression test that verifies list order is unchanged after pressing Enter on an already-settled search. Closes #473 ## Test plan - `flutter test test/widget/email_list_screen_test.dart` — all 24 tests pass, including the new "pressing Enter after search settles does not reorder results" - Manually: type a query in folder view search, wait for results to settle, press Enter — list order must not change 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.