mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-24 09:46:36 +00:00
Prevent document scroll when modal drawer is open (#16033)
This commit is contained in:
parent
d9b0d5765a
commit
d7b8823234
@ -3,8 +3,26 @@ import { styles } from "@material/mwc-drawer/mwc-drawer.css";
|
||||
import { css } from "lit";
|
||||
import { customElement } from "lit/decorators";
|
||||
|
||||
const blockingElements = (document as any).$blockingElements;
|
||||
|
||||
@customElement("ha-drawer")
|
||||
export class HaDrawer extends DrawerBase {
|
||||
protected createAdapter() {
|
||||
return {
|
||||
...super.createAdapter(),
|
||||
trapFocus: () => {
|
||||
blockingElements.push(this);
|
||||
this.appContent.inert = true;
|
||||
document.body.style.overflow = "hidden";
|
||||
},
|
||||
releaseFocus: () => {
|
||||
blockingElements.remove(this);
|
||||
this.appContent.inert = false;
|
||||
document.body.style.overflow = "";
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
static override styles = [
|
||||
styles,
|
||||
css`
|
||||
|
Loading…
x
Reference in New Issue
Block a user