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 mobile sidebar scrolling issue #1787
Fix mobile sidebar scrolling issue #1787
Conversation
|
I don't think it needs to be quite so drastic, I think these changes should fix the issue. .home .sidebar-wrapper {
height: calc(100vh - 48px);
}
.home .sidebar-wrapper .sidebar-bg {
/* remove height: 1000%; */
}
.home .sidebar-wrapper.swiped-in .side-bar {
height: calc(100% - 2px);
overflow-y: auto;
/* remove min-height: calc(100vh - 44px); */
/* remove top: 0; */
/* remove bottom: 0; */
}All can be found here |
|
@Link2Twenty Apologies for the drastic changes to fix the issue 🙏 I've reverted my changes and applied your suggestion, which is much more simpler than what I originally did 😄 |
|
@arnellebalane No need to apologise. Your solution worked too after all 🙂. The CSS solution does have a side effect in which the position of the sidebar is remembered when it is closed and opened again. So we might want to add something to JS to scroll back up on close, though I'm not sure that's crucial. |
|
This is the code the controls the opening and closing of the sidebars Adding this line should make the side-bar scroll back up on close, provided that's the expected behavour. function slideSidebar(side,direction){
if (!document.getElementById("sidebar-wrapper-"+side)){
return;
}
if (direction === "intoView") {
document.getElementById("articles-list").classList.add("modal-open");
document.getElementsByTagName("body")[0].classList.add("modal-open");
document.getElementById("sidebar-wrapper-"+side).classList.add("swiped-in")
document.getElementById("sidebar-wrapper-"+side).scrollTop=0
document.getElementById("articles-list").addEventListener("touchmove", preventDefaultAction, false);
}
else {
document.getElementById("articles-list").classList.remove("modal-open");
document.getElementsByTagName("body")[0].classList.remove("modal-open");
document.getElementById("sidebar-wrapper-"+side).classList.remove("swiped-in");
// New line!
document.getElementById("sidebar-wrapper-"+side).querySelector('.side-bar').scroll(0,0);
document.getElementById("articles-list").removeEventListener("touchmove", preventDefaultAction, false);
}
} |
|
@Link2Twenty I will also try to add scrolling back the sidebar to the top on close in this PR, that sounds like the behavior that I would expect from the sidebar as well. |
|
Hey @arnellebalane, sounds like you're still working on this so I'm going to add WIP to the title. Feel free to change it and leave a comment when it's ready for review again. |
|
@Zhao-Andy Yes I'm still working on this. Thank you! 👍 |
4ea2340
to
33ca1df
Compare
1adf9e9
to
5450081
Compare
|
@Link2Twenty I have updated this PR to make the sidebar scroll back to top when they are closed. The diff for the JS file that I changed will show a lot of changes because ESLint automatically fixed most of the linting issues on that file upon committing my changes 😄 |
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 great! Tested on Android Firefox and Chrome, and iOS Safari.
What type of PR is this? (check all applicable)
Description
When the sidebar is opened in mobile layout, the darkened background (
.sidebar-bg) is longer than the actual sidebar element itself, making it possible to scroll past the bottom of the actual sidebar.The cause of the issue is the
height: 1000%;declaration set in the.sidebar-bgelement. This PRrefactors the sidebar behavior to not rely on theensures that the sidebar wrapper and.sidebar-bgelement as the darkened background. The darkened background is moved to the.side-barelement asbox-shadow, and the.sidebar-bgelements are removed, ensuring that scrolling will not go past the bottom of the sidebar..sidebar-bgelements are sized correctly, and that the sidebar does not overflow the wrapper. With the sidebar always within the wrapper, the darkened background will not scroll as well.Related Tickets & Documents
#1746
Mobile & Desktop Screenshots/Recordings (if there are UI changes)
UI stays the same after the changes are applied.
Added to documentation?