-
Notifications
You must be signed in to change notification settings - Fork 6
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
fix menu background on non-scrollable page #63
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
✅ Deploy Preview for new-sample-app ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
components/shared/ui/menu.tsx
Outdated
|
||
const handleMenuClick = (menuId: string | number): void => { | ||
setActiveMenu(menuId === activeMenu ? -1 : menuId); | ||
}; | ||
|
||
useEffect(() => { | ||
// set is scrolled to show the menu when scrolling is not possible | ||
setIsScrolled(document.body.scrollHeight <= window.innerHeight); |
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.
I don't like mixing the two concepts. You claim that when the page is too short to be scrolled that the page in fact is scrolled with setting this flag to true
. I would prefer having a separate constant (ideally not a state, but a memoized constant created during render) indicating whether the page is scrollable or not.
components/shared/ui/menu.tsx
Outdated
useEffect(() => { | ||
// set is scrolled to show the menu when scrolling is not possible | ||
setIsScrolled(document.body.scrollHeight <= window.innerHeight); | ||
}, [router]); |
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.
Why do you need the router here? The component doesn't re-mount on navigating somewhere else? Also why do you use the whole router
project as a dependency, isn't just the path property enough?
5256c02
to
55abec1
Compare
8ffcea5
to
dcc831e
Compare
dcc831e
to
d21f927
Compare
Motivation
Which issue does this fix? Fixes #62
If no issue exists, what is the fix or new feature? Were there any reasons to fix/implement things that are not obvious?
Checklist
How to test
If manual testing is required, what are the steps?