Skip to content

Conversation

@thatblindgeye
Copy link
Collaborator

Closes #26

@thatblindgeye thatblindgeye requested a review from mcoker March 3, 2025 14:48
@thatblindgeye
Copy link
Collaborator Author

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)

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',
Copy link

Choose a reason for hiding this comment

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

👍

Copy link

@mcoker mcoker left a 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

Copy link
Contributor

@dlabaj dlabaj left a 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.

@thatblindgeye thatblindgeye requested a review from dlabaj March 5, 2025 17:46
Comment on lines 21 to 42
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()
Copy link
Contributor

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

Copy link
Contributor

@wise-king-sullyman wise-king-sullyman left a comment

Choose a reason for hiding this comment

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

 🚀 

🔥

@wise-king-sullyman wise-king-sullyman merged commit aa7850b into patternfly:main Mar 6, 2025
2 checks passed
@github-actions
Copy link

github-actions bot commented Mar 6, 2025

🎉 This PR is included in version 1.0.10 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug - Sidebar content disappears

5 participants