Skip to content

Commit 02c5756

Browse files
authored
Merge pull request #108 from boostcampwm-2024/refactor-fe-#107
전체 화면 상태에서 뒤로 가기 시 화면 축소 기능 구현
2 parents e11ebeb + 280e4c8 commit 02c5756

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

apps/frontend/src/widgets/EditorView/model/useEditorView.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,28 @@ import { useEdtorConnection } from "@/features/editor/model/useEditorConnection"
88

99
export const useEditorView = () => {
1010
const { currentPage } = usePageStore();
11-
const { isPanelOpen, isMaximized, setIsPanelOpen } = useEditorStore();
11+
const { isPanelOpen, isMaximized, setIsPanelOpen, toggleMaximized } =
12+
useEditorStore();
1213
useEdtorConnection(currentPage);
1314
const { editor } = useConnectionStore();
1415
const { users } = useUserStore();
1516

17+
useEffect(() => {
18+
if (isMaximized) {
19+
history.pushState(null, "");
20+
}
21+
22+
const handlePopState = () => {
23+
toggleMaximized();
24+
};
25+
26+
window.addEventListener("popstate", handlePopState);
27+
28+
return () => {
29+
window.removeEventListener("popstate", handlePopState);
30+
};
31+
}, [isMaximized]);
32+
1633
useEffect(() => {
1734
setIsPanelOpen(!!currentPage);
1835
}, [currentPage]);

0 commit comments

Comments
 (0)