Skip to content

[Code scan] Define the mobile menu no-scroll state in CSS #88

Description

@njzjz

This issue is a result of a Codex global code scan of deepmodeling/deepmodeling_sphinx at commit 156679f.

Problem

banner.js toggles body.no-scroll when the mobile menu opens and closes, but banner.css does not define a body.no-scroll rule. The class is therefore inert and does not prevent background page scrolling.

Code references:

element.addEventListener("click", function (e) {
e.preventDefault();
document.querySelector(".mobile-main-menu").classList.add("open");
document.body.classList.add("no-scroll");
mobileMenu.listenForResize();
});

close: function () {
document.querySelector(".mobile-main-menu").classList.remove("open");
document.body.classList.remove("no-scroll");
// Remove the resize event listener
if (this.resizeHandler) {
window.removeEventListener("resize", this.resizeHandler);
this.resizeHandler = null;
}

.mobile-main-menu {
display: none;
}
.mobile-main-menu.open {
background:
radial-gradient(
circle at top left,
rgba(37, 99, 235, 0.28),
transparent 24rem
),
#0f172a;
display: block;
height: 100%;
left: 0;
margin-left: auto;
margin-right: auto;
min-height: 100%;
position: fixed;
right: 0;
top: 0;
width: 100%;
z-index: 99999;
}

Impact

On small screens, opening the fixed mobile menu can still allow the page behind it to scroll. This makes the overlay feel unstable and can move the underlying document while the menu is open.

Suggested fix

Add an explicit rule such as body.no-scroll { overflow: hidden; }, and consider the iOS/touch-scrolling behavior if the menu content itself needs to scroll.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions