Skip to content

fix: Drawer pop() after item is selected#629

Open
chetanr25 wants to merge 1 commit intoCCExtractor:mainfrom
chetanr25:drawer_closing_issue
Open

fix: Drawer pop() after item is selected#629
chetanr25 wants to merge 1 commit intoCCExtractor:mainfrom
chetanr25:drawer_closing_issue

Conversation

@chetanr25
Copy link

@chetanr25 chetanr25 commented Mar 15, 2026

Description

Fix navigation drawer not closing on selection

Added Navigator.pop to the drawer menu items (Profile, Reports, Settings). Previously, the drawer stayed open in the background when navigating to other screens, which made the UI look glitchy when pressing back.

Fixes

Fixes: #628

Screenshots

Before

FILE.2026-03-15.19.03.53.mp4

After

FILE.2026-03-15.19.04.04.mp4

Summary by CodeRabbit

Bug Fixes

  • Navigation drawer now automatically closes when users navigate to Profile, Reports, About, and Settings sections. This ensures a smoother navigation experience by dismissing the drawer before the destination screen loads.

@coderabbitai
Copy link

coderabbitai bot commented Mar 15, 2026

📝 Walkthrough

Walkthrough

The pull request adds automatic drawer closure on navigation within the nav drawer component. The change calls Navigator.of(context).pop() before each navigation action for Profile, Reports variants, About, and Settings. This ensures the drawer closes immediately when a menu item is selected, preventing it from remaining visible in the background.

Changes

Cohort / File(s) Summary
NavDrawer Drawer Closure
lib/app/modules/home/views/nav_drawer.dart
Added Navigator.of(context).pop() calls before navigation actions for PROFILE, REPORTS (and variants), ABOUT, and SETTINGS menu items to ensure the drawer closes prior to screen transitions.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐰 The drawer now knows when to hide,
A courteous pop before each stride.
No more lingering shadows of fame,
Smooth navigation—the drawer's new name! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding Navigator.pop() to close the drawer after menu item selection.
Description check ✅ Passed The description includes a clear summary of the fix, references issue #628, and provides before/after screenshots. All key template sections are adequately addressed.
Linked Issues check ✅ Passed The PR successfully implements the requirements from issue #628 by adding Navigator.pop() to close the drawer when Profile, Reports, or Settings menu items are selected.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the drawer closing behavior specified in issue #628; no out-of-scope modifications are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

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.

Tip

You can customize the high-level summary generated by CodeRabbit.

Configure the reviews.high_level_summary_instructions setting to provide custom instructions for generating the high-level summary.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
lib/app/modules/home/views/nav_drawer.dart (1)

89-90: Consider extracting a shared “close drawer then navigate” helper.

The same close-then-route sequence is repeated in several handlers, which makes future edits easy to miss.

♻️ Suggested refactor
@@
   `@override`
   Widget build(BuildContext context) {
+    void closeDrawer() => Navigator.of(context).pop();
+
@@
                 onTap: () {
-                  Navigator.of(context).pop();
+                  closeDrawer();
                   Get.toNamed(Routes.PROFILE);
                 },
@@
                   onTap: () {
-                    Navigator.of(context).pop();
+                    closeDrawer();
                     Get.toNamed(Routes.REPORTS);
                   },
@@
                   onTap: () {
-                    Navigator.of(context).pop();
+                    closeDrawer();
                     Get.to(() => ReportsHomeTaskc());
                   },
@@
                   onTap: () {
-                    Navigator.of(context).pop();
+                    closeDrawer();
                     Get.to(() => ReportsHomeReplica());
                   },
@@
                 onTap: () {
-                  Navigator.of(context).pop();
+                  closeDrawer();
                   Get.toNamed(Routes.ABOUT);
                 },
@@
                 onTap: () async {
-                  Navigator.of(context).pop();
+                  closeDrawer();
                   final SharedPreferences prefs =
                       await SharedPreferences.getInstance();

Also applies to: 104-106, 120-122, 136-138, 149-151, 161-172

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/app/modules/home/views/nav_drawer.dart` around lines 89 - 90, Extract the
repeated "close drawer then navigate" pattern into a single helper (e.g.,
closeAndNavigate) and replace each pair of Navigator.of(context).pop();
Get.toNamed(...) calls with a single call to that helper; the helper should
accept the BuildContext and the route name (or an enum/Routes value) and
internally call Navigator.of(context).pop() then Get.toNamed(route) so handlers
across nav_drawer.dart (including the calls around Navigator.of(context).pop();
Get.toNamed(Routes.PROFILE); and the other similar pairs) use the shared
function.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@lib/app/modules/home/views/nav_drawer.dart`:
- Around line 89-90: Extract the repeated "close drawer then navigate" pattern
into a single helper (e.g., closeAndNavigate) and replace each pair of
Navigator.of(context).pop(); Get.toNamed(...) calls with a single call to that
helper; the helper should accept the BuildContext and the route name (or an
enum/Routes value) and internally call Navigator.of(context).pop() then
Get.toNamed(route) so handlers across nav_drawer.dart (including the calls
around Navigator.of(context).pop(); Get.toNamed(Routes.PROFILE); and the other
similar pairs) use the shared function.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1f938a4e-74f5-4d88-89d8-bc7f75b2b851

📥 Commits

Reviewing files that changed from the base of the PR and between f058b4a and af2e90a.

📒 Files selected for processing (1)
  • lib/app/modules/home/views/nav_drawer.dart

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.

Drawer should close automatically when navigating to a new screen

1 participant