Skip to content

Conversation

@roldy
Copy link

@roldy roldy commented Dec 18, 2025

Fixes #13517

Summary by CodeRabbit

  • Refactor
    • Improved survey criteria reset behavior when navigating without URL parameters.
    • Optimized component initialization sequence for better state management.

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

@coderabbitai
Copy link

coderabbitai bot commented Dec 18, 2025

Walkthrough

The changes fix the Survey reset filters functionality by modifying how the SurveysView handles criteria clearing. When navigating to a null criteria state, a callback now properly removes SurveyCriteria from ViewModelProviders instead of direct navigation. Additionally, filter fields (free text and disease) are explicitly reset to null when entering the view without URL parameters.

Changes

Cohort / File(s) Summary
Survey filter reset logic
sormas-ui/src/main/java/de/symeda/sormas/ui/survey/SurveysView.java
Modified SurveyGridComponent navigation callback to remove SurveyCriteria from ViewModelProviders before navigating to null criteria state. Added explicit reset of free text and disease fields when view enters with no URL parameters.
Button component initialization
sormas-ui/src/main/java/de/symeda/sormas/ui/utils/components/ApplyResetButtonsComponent.java
Changed initialization order of resetButton and applyButton in constructor; resetButton creation now occurs after applyButton setup while maintaining final component composition.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Verify that the ViewModelProviders cleanup properly prevents filter state persistence
  • Confirm that explicit field resets (free text and disease) work correctly with the new navigation flow
  • Validate that button initialization order change doesn't affect component behavior or styling

Poem

🐰 The survey filters now dance with grace,
No phantom states to clutter up the place,
Reset clears the board with care,
Free text and disease—both vanish in the air,
Buttons reordered, logic now is bright! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the issue number and the main change: fixing the Survey Reset filters action.
Description check ✅ Passed The description includes the required issue reference format 'Fixes #13517', meeting the minimal template requirements.
Linked Issues check ✅ Passed The code changes address the bug: SurveyCriteria is removed before navigation and filter fields are reset to null, directly fixing the reported incorrect reset behavior.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing the reset functionality in SurveysView and ordering adjustments in ApplyResetButtonsComponent, directly related to the issue.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bugfix-13517-survey-reset-filters-action

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between af6249b and ee68f93.

📒 Files selected for processing (2)
  • sormas-ui/src/main/java/de/symeda/sormas/ui/survey/SurveysView.java (2 hunks)
  • sormas-ui/src/main/java/de/symeda/sormas/ui/utils/components/ApplyResetButtonsComponent.java (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: SORMAS CI
🔇 Additional comments (3)
sormas-ui/src/main/java/de/symeda/sormas/ui/utils/components/ApplyResetButtonsComponent.java (1)

25-27: Clarify the necessity of this reordering change.

The resetButton initialization has been moved after the applyButton setup, which changes the initialization order. While this doesn't affect functionality, it's unclear how this change relates to fixing the Survey reset filters issue. If this reordering serves a specific purpose (e.g., tab order, focus behavior), please clarify. Otherwise, this appears to be an unrelated refactor.

sormas-ui/src/main/java/de/symeda/sormas/ui/survey/SurveysView.java (2)

33-36: Good fix for clearing criteria state on reset.

The reset callback now properly removes the SurveyCriteria from ViewModelProviders before navigation, ensuring no stale filter state is retained. This addresses the root cause where the reset action was filtering instead of clearing.


53-56: No action needed. All filter fields in SurveyCriteria are being properly reset.

The code explicitly clears both filterable fields defined in SurveyCriteria: freeText and disease. SurveyCriteria contains no additional filter fields beyond these two, so the reset logic is complete and correct.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sormas-vitagroup
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Survey Reset filters action is wrong

3 participants