Skip to content
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

Sidebar bug in Next.js 14.1.0 #212

Open
Snarloff opened this issue Jan 29, 2024 · 9 comments
Open

Sidebar bug in Next.js 14.1.0 #212

Snarloff opened this issue Jan 29, 2024 · 9 comments

Comments

@Snarloff
Copy link

Snarloff commented Jan 29, 2024

Hello!

I have a bug in the package using it in Next.js version 14. The bug is that when entering the mobile device, the sidebar should start closed since it is responsive. However, as shown in the image, it starts open, not being responsive. I ran the sidebar by taking Playgroud.tsx and putting it in a Next project.

Screenshots

image

Running on

Windows 11
Next.js 14.1.0
Components declares with "use client"

I carried out the same test with Vite and it ran normally, being responsive.

Warning: Prop `className` did not match. Server: "ps-sidebar-root text-default-500 h-screen css-1rwe39e" Client: "ps-sidebar-root ps-broken text-default-500 h-screen css-1rwe39e"
@azouaoui-med
Copy link
Owner

have you tried adding 'use client' to the sidebar wrapper ?!

@Snarloff
Copy link
Author

Snarloff commented Feb 2, 2024

have you tried adding 'use client' to the sidebar wrapper ?!

Yes! In all components too, but the same error

@RaFeNiX
Copy link

RaFeNiX commented Feb 24, 2024

Could you replicate this out of the Playground @Snarloff ?
I Have had some issues with The playground on the past. Maybe something related to config as Next 14 brings up some big changes over settings.

@Snarloff
Copy link
Author

Could you replicate this out of the Playground @Snarloff ? I Have had some issues with The playground on the past. Maybe something related to config as Next 14 brings up some big changes over settings.

I replicated it in Playground and in my normal code and it gives this error :/

@jweekley7
Copy link

I having this issue too. Anyone made any progress yet?

@jweekley7
Copy link

This has something to do with the breakpoint. This is my workaround
image

Copy link

stale bot commented May 5, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label May 5, 2024
@fchoi1
Copy link

fchoi1 commented May 9, 2024

A better workaround is to check for component mount since there is a mismatch in the classname for broken sidebar
since the useEffect is done on client side render

  const [mounted, setMounted] = useState(false);
  useEffect(() => setMounted(true), []);

   return (mounted && (
      <Sidebar> .... <Sidebar/>))

@stale stale bot removed the stale label May 9, 2024
@Yugi-2
Copy link

Yugi-2 commented May 14, 2024

The "mounted" workaround was not preferable to me as there's an awkward second before the sidebar loads in. Instead I used CSS media queries to hide the sidebar on initial load when it is less than the breakpoint width

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants