修复 Agent 对话框覆盖地图区域的问题
This commit is contained in:
@@ -3,11 +3,10 @@
|
|||||||
import React, {
|
import React, {
|
||||||
useCallback,
|
useCallback,
|
||||||
useEffect,
|
useEffect,
|
||||||
useLayoutEffect,
|
|
||||||
useRef,
|
useRef,
|
||||||
useState,
|
useState,
|
||||||
} from "react";
|
} from "react";
|
||||||
import { Box, Drawer, alpha, useMediaQuery, useTheme } from "@mui/material";
|
import { Box, Drawer, alpha, useTheme } from "@mui/material";
|
||||||
|
|
||||||
import type { AgentModel } from "@/lib/chatStream";
|
import type { AgentModel } from "@/lib/chatStream";
|
||||||
import { AgentComposer } from "./AgentComposer";
|
import { AgentComposer } from "./AgentComposer";
|
||||||
@@ -33,7 +32,6 @@ export const GlobalChatbox: React.FC<Props> = ({ open, onClose }) => {
|
|||||||
const bottomRef = useRef<HTMLDivElement>(null);
|
const bottomRef = useRef<HTMLDivElement>(null);
|
||||||
const inputRef = useRef<HTMLInputElement | null>(null);
|
const inputRef = useRef<HTMLInputElement | null>(null);
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const isDesktop = useMediaQuery(theme.breakpoints.up("sm"));
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
speechState,
|
speechState,
|
||||||
@@ -165,32 +163,6 @@ export const GlobalChatbox: React.FC<Props> = ({ open, onClose }) => {
|
|||||||
};
|
};
|
||||||
}, [isResizing]);
|
}, [isResizing]);
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
|
||||||
const body = document.body;
|
|
||||||
const html = document.documentElement;
|
|
||||||
const previousBodyPaddingRight = body.style.paddingRight;
|
|
||||||
const previousBodyTransition = body.style.transition;
|
|
||||||
const previousBodyBoxSizing = body.style.boxSizing;
|
|
||||||
const previousHtmlBoxSizing = html.style.boxSizing;
|
|
||||||
const reservedWidth = open && isDesktop ? `${width}px` : "0px";
|
|
||||||
|
|
||||||
body.style.boxSizing = "border-box";
|
|
||||||
html.style.boxSizing = "border-box";
|
|
||||||
body.style.paddingRight = reservedWidth;
|
|
||||||
body.style.transition = isResizing
|
|
||||||
? previousBodyTransition
|
|
||||||
: [previousBodyTransition, "padding-right 240ms cubic-bezier(0.2, 0.8, 0.2, 1)"]
|
|
||||||
.filter(Boolean)
|
|
||||||
.join(", ");
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
body.style.paddingRight = previousBodyPaddingRight;
|
|
||||||
body.style.transition = previousBodyTransition;
|
|
||||||
body.style.boxSizing = previousBodyBoxSizing;
|
|
||||||
html.style.boxSizing = previousHtmlBoxSizing;
|
|
||||||
};
|
|
||||||
}, [isDesktop, isResizing, open, width]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Drawer
|
<Drawer
|
||||||
anchor="right"
|
anchor="right"
|
||||||
@@ -200,7 +172,10 @@ export const GlobalChatbox: React.FC<Props> = ({ open, onClose }) => {
|
|||||||
hideBackdrop
|
hideBackdrop
|
||||||
disableScrollLock
|
disableScrollLock
|
||||||
disableEnforceFocus
|
disableEnforceFocus
|
||||||
sx={{ zIndex: (muiTheme) => muiTheme.zIndex.modal + 100 }}
|
sx={{
|
||||||
|
zIndex: (muiTheme) => muiTheme.zIndex.modal + 100,
|
||||||
|
pointerEvents: "none",
|
||||||
|
}}
|
||||||
PaperProps={{
|
PaperProps={{
|
||||||
sx: {
|
sx: {
|
||||||
width: { xs: "100%", sm: width },
|
width: { xs: "100%", sm: width },
|
||||||
@@ -208,6 +183,7 @@ export const GlobalChatbox: React.FC<Props> = ({ open, onClose }) => {
|
|||||||
boxShadow: "none",
|
boxShadow: "none",
|
||||||
overflow: open ? "visible" : "hidden",
|
overflow: open ? "visible" : "hidden",
|
||||||
zIndex: (muiTheme) => muiTheme.zIndex.modal + 100,
|
zIndex: (muiTheme) => muiTheme.zIndex.modal + 100,
|
||||||
|
pointerEvents: "auto",
|
||||||
transition: isResizing ? "none" : undefined,
|
transition: isResizing ? "none" : undefined,
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
|
|||||||
Reference in New Issue
Block a user