-
Notifications
You must be signed in to change notification settings - Fork 11
fix(PageToggle): resolved sidebar not collapsing correctly #28
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
Conversation
|
FYI I'm going to push an update for the alternative method that we had gone over last Friday. Per Coker that alternative method would be the more correct way -- we can tweak things further as a followup once patternfly/patternfly#7377 goes in (this core work would mean not having to apply the classes on the astro island and just having PageSidebar as a child of that island) |
da9cac7 to
c1acd79
Compare
src/components/PageToggle.tsx
Outdated
| sideBarIsland.classList.add('pf-v6-c-page__sidebar', 'pf-m-expanded') | ||
| sideBarIsland.classList.add( | ||
| 'pf-v6-c-page__sidebar', | ||
| $isNavOpen ? 'pf-m-expanded' : 'pf-m-collapsed', |
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.
👍
69e4fce to
eb9296c
Compare
mcoker
left a comment
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.
LGTM!
Not a blocker or anything but the hard-coded classes will need manual updates with new PF versions (pf-v6-... to pf-v7-...). At least for those (and probably the modifiers, too, but not as big of a deal) I wonder if we should import '@patternfly/react-styles/css/components/Page/page' so we can use styles.pageSidebar instead of pf-v6-c-page__sidebar
dlabaj
left a comment
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.
Looks like there's a warning for applySidebarStylesToIsland in the hook.
71ccaa3 to
4365970
Compare
src/components/PageToggle.tsx
Outdated
| function applySidebarStylesToIsland() { | ||
| const isClientSide = typeof window !== 'undefined' | ||
| const sideBarIsland = | ||
| document.getElementById('page-sidebar-body')?.parentElement | ||
|
|
||
| if (!isClientSide || !sideBarIsland) { | ||
| return | ||
| } | ||
|
|
||
| if (!sideBarIsland.classList.contains(styles.pageSidebar)) { | ||
| sideBarIsland.classList.add( | ||
| styles.pageSidebar, | ||
| $isNavOpen ? styles.modifiers.expanded : styles.modifiers.collapsed, | ||
| ) | ||
| } else { | ||
| sideBarIsland.classList.toggle(styles.modifiers.expanded) | ||
| sideBarIsland.classList.toggle(styles.modifiers.collapsed) | ||
| } | ||
| sideBarIsland.setAttribute('aria-hidden', `${!$isNavOpen}`) | ||
| } | ||
|
|
||
| applySidebarStylesToIsland() |
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.
🤔 is there even much reason to wrap all this in a function and effectively use it as a named IIFE? Seems like we could just have this logic straight in the effect
4365970 to
d32e1d2
Compare
wise-king-sullyman
left a comment
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 PR is included in version 1.0.10 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Closes #26