Skip to content

Commit 24fe714

Browse files
authored
fix: keep the window height when the popover is open. (#958)
1 parent e92eee1 commit 24fe714

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

src/components/SearchChat/index.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {
3434
visibleSearchBar,
3535
} from "@/utils";
3636
import { useTauriFocus } from "@/hooks/useTauriFocus";
37+
import { POPOVER_PANEL_SELECTOR } from "@/constants";
3738

3839
interface SearchChatProps {
3940
isTauri?: boolean;
@@ -97,14 +98,16 @@ function SearchChat({
9798

9899
const inputRef = useRef<string>();
99100
const isChatModeRef = useRef(false);
101+
const [hideMiddleBorder, setHideMiddleBorder] = useState(false);
100102

101103
const setWindowSize = useCallback(() => {
102104
const width = 680;
103105
let height = 590;
104106

105107
const updateAppDialog = document.querySelector("#update-app-dialog");
108+
const popoverPanelEl = document.querySelector(POPOVER_PANEL_SELECTOR);
106109

107-
if (!updateAppDialog && !canNavigateBack() && !inputRef.current) {
110+
if (!updateAppDialog && !canNavigateBack() && !inputRef.current && !popoverPanelEl) {
108111
const { windowMode } = useAppearanceStore.getState();
109112

110113
if (windowMode === "compact") {
@@ -118,7 +121,10 @@ function SearchChat({
118121
}
119122

120123
height = Math.min(height, 88);
124+
setHideMiddleBorder(height < 590);
121125
}
126+
} else {
127+
setHideMiddleBorder(false);
122128
}
123129

124130
platformAdapter.setWindowSize(width, height);
@@ -278,8 +284,6 @@ function SearchChat({
278284
});
279285

280286
const opacity = useAppearanceStore((state) => state.opacity);
281-
const windowMode = useAppearanceStore((state) => state.windowMode);
282-
const isCompact = windowMode === "compact";
283287

284288
useEffect(() => {
285289
if (isTauri) {
@@ -341,8 +345,8 @@ function SearchChat({
341345
data-tauri-drag-region={isTauri}
342346
className={clsx(
343347
"p-2 w-full flex justify-center transition-all duration-500",
344-
!isCompact && "border-[#E6E6E6] dark:border-[#272626]",
345-
!isCompact && [isTransitioned ? "border-t" : "border-b"],
348+
!hideMiddleBorder && "border-[#E6E6E6] dark:border-[#272626]",
349+
!hideMiddleBorder && [isTransitioned ? "border-t" : "border-b"],
346350
{
347351
"min-h-[84px]": visibleSearchBar() && visibleFilterBar(),
348352
}

0 commit comments

Comments
 (0)