fix: Do not open side navigation from close button - #4838
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes a regression introduced after #4688 where the side navigation “close” button could act as a toggle and reopen navigation when it was already closed under the navigationCloseBehavior="hide" mode (notably affecting test-utils driven interactions).
Changes:
- Adjusted the navigation close button click logic to avoid reopening the navigation when it is not meant to be collapsible.
- Added a unit test asserting the close button does not reopen navigation when already closed (hide behavior).
- Added a unit test asserting the close button toggles open/closed when
navigationCloseBehavior="collapse"(collapsed-rail behavior).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/app-layout/visual-refresh-toolbar/navigation/index.tsx | Updates close button click behavior to prevent unintended reopening when navigation isn’t collapsible. |
| src/app-layout/tests/navigation-collapsed.test.tsx | Adds coverage for toggling behavior in collapsible (collapse) mode. |
| src/app-layout/tests/app-layout-navigation.test.tsx | Adds regression test ensuring close button does not reopen navigation when already closed (hide mode). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ariaExpanded={navigationCollapsible && !isMobile ? navigationOpen : undefined} | ||
| iconName={navigationCollapsed ? 'angle-right' : isMobile ? 'close' : 'angle-left'} | ||
| onClick={() => onNavigationToggle(!navigationOpen)} | ||
| onClick={() => onNavigationToggle(navigationCollapsible ? !navigationOpen : false)} | ||
| variant="icon" |
There was a problem hiding this comment.
True, but this will not be called in a real environment when navigation is already closed
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4838 +/- ##
=======================================
Coverage 97.62% 97.62%
=======================================
Files 956 956
Lines 31012 31012
Branches 11409 11411 +2
=======================================
Hits 30277 30277
+ Misses 728 688 -40
- Partials 7 47 +40 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Description
After #4688, clicking the side navigation close button works as a toggle button, i.e, it closes the side navigation when it is open, but it also opens it if it's closed. This is meant for the newly introduced "collapse" behavior. In the "hide" behavior the button cannot really be closed by real users because the close button has
display: closewhen the side navigation is closed, but it is still accessible by the test utils, and this change in behavior broke a customer's tests (build:7949323707)How has this been tested?
7950984806Review checklist
The following items are to be evaluated by the author(s) and the reviewer(s).
Correctness
CONTRIBUTING.md.CONTRIBUTING.md.Security
checkSafeUrlfunction.Testing
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.