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 hamburger menu scrolling #15000
Fix hamburger menu scrolling #15000
Conversation
|
Thank you for opening this PR! We appreciate you! For all pull requests coming from third-party forks we will need to A Forem Team member will review this contribution and get back to |
|
Hey, there's still something off with pulling down - it does trigger the refresher in the background. Nagranie.z.ekranu.2021-10-11.o.18.56.18.mov |
| if (typeof window.PullToRefresh !== 'undefined') { | ||
| document.body.dataset.leftNavState === 'open' | ||
| ? window.PullToRefresh.destroyAll() | ||
| : window.PullToRefresh.init(); |
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 prevents executing pull to refresh, but I'm not sure this is the correct way to handle PullToRefresh.
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.
Just repeating the code here for my own understanding, when calling toggleBurgerMenu (expanding the left nav menu), this will remove all setup PullToRefresh handlers via the public destroyAll function, and if we're toggling to closed, we set it back up.
I noticed the place we call init() originally, in base.js, we pass an option object
{
mainElement: 'body',
passive: true,
onRefresh: function(){
window.location.reload();
}
}Do you think we should do that here as well? I'm not familiar with the code but the public api you're calling for init expects an object o and sets undefined to an empty object.
I assume these options should be reset when you call init() here. Or the existing options somehow accessed, stored locally, and restored rather than being rebuilt, I don't see an obvious path to do that in the pull to refresh public api. Since storing/restoring is an efficiency concern, rather than a correctness issue, I don't think it's worth spending a lot of time on that.
It looks like there are defaults which passing an empty options object will use - and these include the specified options apart from passive: true.
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.
Thank you for your review!
I looked into pulltorefresh.js and found shouldPullToRefresh function which listed conditions for when to execute pulling to refresh. So I added this condition to shouldPullToRefresh instead of destroying the PullToRefresh object.
It looks like there are defaults which passing an empty options object will use - and these include the specified options apart from passive: true.
passive: true might be related to this. According to it, it could be better to specify passive: true if I call PullToRefresh's init().
| if (typeof window.PullToRefresh !== 'undefined') { | ||
| document.body.dataset.leftNavState === 'open' | ||
| ? window.PullToRefresh.destroyAll() | ||
| : window.PullToRefresh.init(); |
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.
Just repeating the code here for my own understanding, when calling toggleBurgerMenu (expanding the left nav menu), this will remove all setup PullToRefresh handlers via the public destroyAll function, and if we're toggling to closed, we set it back up.
I noticed the place we call init() originally, in base.js, we pass an option object
{
mainElement: 'body',
passive: true,
onRefresh: function(){
window.location.reload();
}
}Do you think we should do that here as well? I'm not familiar with the code but the public api you're calling for init expects an object o and sets undefined to an empty object.
I assume these options should be reset when you call init() here. Or the existing options somehow accessed, stored locally, and restored rather than being rebuilt, I don't see an obvious path to do that in the pull to refresh public api. Since storing/restoring is an efficiency concern, rather than a correctness issue, I don't think it's worth spending a lot of time on that.
It looks like there are defaults which passing an empty options object will use - and these include the specified options apart from passive: true.
83eb4b8
to
140261f
Compare
140261f
to
8c26886
Compare
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.
Thanks for the fix @takmar! 🚀
What type of PR is this? (check all applicable)
Description
The reason for the problem mentioned above is that the body element is enabled to scroll when the hamburger menu is opened. So I added
overflow: hiddentobody[data-left-nav-state='open']selector so that it prevents scroll the body while opening the menu.data-left-nav-state='open'is set when the hamburger menu is opened. The code is below.forem/app/javascript/topNavigation/utilities.js
Lines 129 to 133 in 2e21050
Related Tickets & Documents
Closes #14757
QA Instructions, Screenshots, Recordings
UI accessibility concerns?
Added/updated tests?
[Forem core team only] How will this change be communicated?
[optional] Are there any post deployment tasks we need to perform?
[optional] What gif best describes this PR or how it makes you feel?