-
Notifications
You must be signed in to change notification settings - Fork 217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(feat) O3-4425 - add ability to define collapsed left nav #1279
base: main
Are you sure you want to change the base?
Conversation
* nav when the hamburger menu is clicked on in tablet mode. See side-menu-panel.component.tsx | ||
* | ||
* Use of this component by anything other than <SideMenuPanel> (where isChildOfHeader == false) | ||
* is deprecated; it simply renders nothing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit hacky. If we feel comfortable with this, we can opt for more aggressive breaking change where we stop exporting <LeftNavMenu>
in @openmrs/esm-framework
, and force other ESMs to remove it.
Size Change: -152 kB (-2.4%) Total Size: 6.2 MB
ℹ️ View Unchanged
|
@ibacher @denniskigen @samuelmale @vasharma05 This touches core code, so I'm hoping to get feedback from outside PIH. Please review when you have a chance. Thanks! |
Requirements
feat
,fix
, orchore
, among others). See existing PR titles for inspiration.For changes to apps
If applicable
Summary
This PR adds the ability for apps to define a left nav that's always collapsed into the top nav hamburger menu.
This PR also includes refactoring to remove the need to render
<LeftNavMenu>
within the home or patient-chart app. Currently, the home / patient-chart app needs to render<LeftNavMenu>
in its root component in order for the left nav to show in desktop mode. The top nav, however, also has a<SideMenuPanel>
, which renders the menu when in tablet mode and the hamburger button is toggled on. (Incidentally,<SideMenuPanel>
actually uses<LeftNavMenu>
as child component)Screenshot:
![image](https://private-user-images.githubusercontent.com/509602/409196923-600a46fa-f25d-47c0-96c7-1ac1aaa844df.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxNDQ4NDMsIm5iZiI6MTczOTE0NDU0MywicGF0aCI6Ii81MDk2MDIvNDA5MTk2OTIzLTYwMGE0NmZhLWYyNWQtNDdjMC05NmM3LTFhYzFhYWE4NDRkZi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjA5JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIwOVQyMzQyMjNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0yNDk3OTQ0YTc5MWVmNDNmY2E2OTViNTFjOTVlOWJhOWRmNTQ2ODUyYTFmNjEzZTgyYjljMzI5ZjA0MzIyZTY5JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.q-SayQMlk46VnBzcKiICvKZI1tZpsgf_8Rv7cPtYd_E)
<LeftNavMenu>
rendered by home app:Screenshot:
![image](https://private-user-images.githubusercontent.com/509602/409197289-dcf6c4f6-ed12-45ef-836d-f311bbc1be69.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxNDQ4NDMsIm5iZiI6MTczOTE0NDU0MywicGF0aCI6Ii81MDk2MDIvNDA5MTk3Mjg5LWRjZjZjNGY2LWVkMTItNDVlZi04MzZkLWYzMTFiYmMxYmU2OS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjA5JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIwOVQyMzQyMjNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1lZTQzZTMwY2MwMmY1ZWM3NjUyMDg5MmNlZjYyZjIzZWU0OTg0MTRjYjJjN2U1ZGEyMDI0N2FlMWEzNGFkODgzJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.g-UVka9uREyYZBNW5o-DaGwxEDAwoiIW_fBbNqRXEwM)
<SideMenuPanel>
rendered by primary-navigation-app:The
<LeftNavMenu>
is a carbon's<SideNav>
component, which is aposition: fixed
element. This means we shouldn't really need the home or patient chart app to render it as part of its component tree. The refactoring makes it so the that the<SideMenuPanel>
renders both:Screenshots
Video of the home app with this change. No noticeable difference from before. (Not part of this PR, but in the video capture,
<LeftNavMenu>
is removed from the home app.)https://github.com/user-attachments/assets/f89bae32-5b20-4270-aa44-8874fff62cf4
Video of the dispensing app with this change, The dispensing app added the following to define the left nav to be always collapsed:
OpenMRS.Mozilla.Firefox.2025-02-03.16-48-33.mp4
Related Issue
https://openmrs.atlassian.net/browse/O3-4425
Other
I attempted to refactor
<LeftNavMenu>
hoping this will give us a cleaner way to define a collapsed left nav. While this change removes the need to render<LeftNavMenu>
in home / patient-chart, it fails to completely abstract the left nav logic away from those apps. In particular, the home dashboard actually needs to maintain amargin-left
in order to be rendered to the right of the left nav in desktop mode. (That margin is set to 0 in tablet mode).I'm not sure if there is a way around it as the left nav isThis is probably doable with a more invasive change by overriding theposition: fixed
.position: fixed
in the carbon<SideNav>
and adding atop-nav-container
div inindex.ejs
(so we can render the top nav there viacreatePortal())
.