Topic: SideNav (SideNavCat/SideNavItem) collapsible issue
sourabha22 pro asked 7 years ago
Hi, there is a regression issue in V4.4.0 with respect to the SideNav where-in the SideNavItem(s) are not displayed on clicking SideNavCat.
There seems to be an issue while applying correct definition of CSS class "collapsible-body" in V4.4.0, which is preventing the side menu items from being displayed. Please find below my analysis/comparison w.r.t V4.3.0
Version 4.3.0:
1) Source code from SideNavCat.js
<Collapse isOpen = {isOpen} className = "collapsible-body">
<ul>
{children}
</ul>
</Collapse>
2) Generated html element (when side nav category is clicked)
<div class="collapse show collapsible-body">..</div>
3) CSS definition in bootstrap.css
.collapse.show {
display: block;
}
Result: Working as expected(Side Nav items are displayed when parent Side Nav Category is clicked/active)
Version 4.4.0:
1) Source code from SideNavCat.js
<Collapse isOpen = {isOpen}>
<div className="collapsible-body">
<ul>
{children}
</ul>
</div>
</Collapse>
2) Generated html element (when side nav category is clicked)
<div class="collapse show">
<div class="collapsible-body">..</div>
</div>
3) CSS definition
a) Following style is defined in SideNav.css [which is included in SideNavCat.js ->require('./SideNav.css');]
.collapsible-body {
display: block;
}
b) Following style is defined in mdb.css
.collapsible-body {
display: none;
}
Observation:
When running re-pro-4.4.0 as a standalone application, expected style (from SideNav.css is applied) because SideNav.css appears after mdb.css in the index.html file
However, when MDB is included as a dependency in CRA application (and when mdb.css imported in index.js), style defined in mdb.css is applied since it is the last style to be included in index.html
and by principle,
"When multiple rules of the same "specificity level" exist, whichever one appears last wins"
I hope this helps to confirm if this is an issue. Thanks.
Jakub Strebeyko staff answered 7 years ago
mdb.min.css
file. Other way is to just add !important
to the display: block
style declaration in SideNav.css
- this will make sure it does not get overwritten, no matter the order of files.
Thanks big time for reaching out with your throughout analysis! This helps us big time.
With Best Regards,
Kuba sourabha22 pro commented 7 years ago
Thank you Kuba for your quick response and suggestions. How will be the solution mentioned above be applicable in context of my application, 1) created using CRA 2) "mdbreact" is included as a package dependency in package.json 3) following lines are included in index.js as mentioned in the quick start guide, import 'font-awesome/css/font-awesome.min.css'; import 'bootstrap/dist/css/bootstrap.min.css'; import 'mdbreact/dist/css/mdb.css'; One temporary solution i can think of (and have tested) is to add SideNav.css in my project alongside my SideNav component and include that as the dependency after mdb.css in index.js import 'font-awesome/css/font-awesome.min.css'; import 'bootstrap/dist/css/bootstrap.min.css'; import 'mdbreact/dist/css/mdb.css'; import './app/layout/sidenav/SideNav.css'; Please advice in case i am missing anything. Thank you.Jakub Strebeyko staff commented 7 years ago
Hi there, Actually, if the solution works it could be the best one yet, as it ensures the CSS rule will be added last every time. Good job! And thanks for taking time and reporting it. With Best Regards, KubaLRuan answered 6 years ago
Jakub Strebeyko staff commented 6 years ago
Hi there LRuan, First advice that pops into my mind is updating your MDB React package to 4.5.0. Issues with SideNavItem and SideNavCat (caused by waves effect in FireFox's event bubbling schema) have been tackled there, resulting in a slight open/close functionality remake, rendering the CSS.collapsible-body
hotfix redundant. Check it out and let me know whether it helped.
Best, Kuba
LRuan commented 6 years ago
Hi, My mdbreact was already upgraded to 4.5, but issue still persistsJakub Strebeyko staff commented 6 years ago
Hello there, I just downloaded the repo and checked out to4.5.0
tag, yarn start
ed it and opened in Chrome - it works. Please share minimum code snippet necessary to reproduce the bug, along with some environment details (a browser version, perhaps?) Thanks.
Best,
Kuba
Closed
This topic is closed.
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Closed
- User: Pro
- Premium support: No
- Technology: MDB React
- MDB Version: -
- Device: -
- Browser: -
- OS: -
- Provided sample code: No
- Provided link: No
sourabha22 pro commented 7 years ago
Other user reported similar issue: https://mdbootstrap.com/support/react-sidebar-accordion/