Skip to content

Commit 1099d28

Browse files
committed
Removed changes related to handle resize event listener. Now just calling the updateWindowDimensions on page load of editor and view mode. If any browser resize happens, user is expected refresh page.
1 parent d87c395 commit 1099d28

File tree

2 files changed

+2
-50
lines changed

2 files changed

+2
-50
lines changed

app/client/src/pages/AppIDE/AppIDE.tsx

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ import { IDE_HEADER_HEIGHT } from "@appsmith/ads";
3939
import { GitApplicationContextProvider } from "git-artifact-helpers/application/components";
4040
import { AppIDEModals } from "ee/pages/AppIDE/components/AppIDEModals";
4141
import { updateWindowDimensions } from "actions/windowActions";
42-
import { debounce } from "lodash";
43-
import { RESIZE_DEBOUNCE_THRESHOLD } from "pages/hooks/constants";
4442

4543
interface EditorProps {
4644
currentApplicationId?: string;
@@ -70,8 +68,6 @@ type Props = EditorProps & RouteComponentProps<BuilderRouteParams>;
7068

7169
class Editor extends Component<Props> {
7270
prevPageId: string | null = null;
73-
private handleResize: (() => void) | null = null;
74-
private debouncedHandleResize: ReturnType<typeof debounce> | null = null;
7571

7672
componentDidMount() {
7773
const { basePageId } = this.props.match.params || {};
@@ -82,22 +78,8 @@ class Editor extends Component<Props> {
8278
this.props.widgetConfigBuildSuccess();
8379
});
8480

85-
// Set up window resize listener for window dimensions
86-
this.handleResize = () => {
87-
this.props.updateWindowDimensions(window.innerHeight, window.innerWidth);
88-
};
89-
90-
// Create debounced version of resize handler
91-
this.debouncedHandleResize = debounce(
92-
this.handleResize,
93-
RESIZE_DEBOUNCE_THRESHOLD * 2,
94-
);
95-
96-
// Set initial dimensions immediately
81+
// Set initial window dimensions
9782
this.props.updateWindowDimensions(window.innerHeight, window.innerWidth);
98-
99-
// Add resize listener with debounced handler
100-
window.addEventListener("resize", this.debouncedHandleResize);
10183
}
10284

10385
shouldComponentUpdate(nextProps: Props) {
@@ -182,13 +164,6 @@ class Editor extends Component<Props> {
182164
componentWillUnmount() {
183165
this.props.resetEditorRequest();
184166
urlBuilder.setCurrentBasePageId(null);
185-
186-
// Clean up window resize listener
187-
if (this.debouncedHandleResize) {
188-
window.removeEventListener("resize", this.debouncedHandleResize);
189-
// Cancel any pending debounced calls
190-
this.debouncedHandleResize.cancel();
191-
}
192167
}
193168

194169
public render() {

app/client/src/pages/AppViewer/AppPage/AppPage.tsx

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import type { WidgetProps } from "widgets/BaseWidget";
99
import { useAppViewerSidebarProperties } from "utils/hooks/useAppViewerSidebarProperties";
1010
import { getIsAnvilLayout } from "layoutSystems/anvil/integrations/selectors";
1111
import { updateWindowDimensions } from "actions/windowActions";
12-
import { debounce } from "lodash";
13-
import { RESIZE_DEBOUNCE_THRESHOLD } from "pages/hooks/constants";
1412

1513
import { PageView, PageViewWrapper } from "./AppPage.styled";
1614
import { useCanvasWidthAutoResize } from "../../hooks/useCanvasWidthAutoResize";
@@ -50,30 +48,9 @@ export function AppPage(props: AppPageProps) {
5048
});
5149
}, [appName, basePageId, pageName]);
5250

53-
// Set up window resize listener for window dimensions
51+
// Set initial window dimensions
5452
useEffect(() => {
55-
const handleResize = () => {
56-
dispatch(updateWindowDimensions(window.innerHeight, window.innerWidth));
57-
};
58-
59-
// Create debounced version of resize handler
60-
const debouncedHandleResize = debounce(
61-
handleResize,
62-
RESIZE_DEBOUNCE_THRESHOLD * 2,
63-
);
64-
65-
// Set initial dimensions immediately
6653
dispatch(updateWindowDimensions(window.innerHeight, window.innerWidth));
67-
68-
// Add resize listener with debounced handler
69-
window.addEventListener("resize", debouncedHandleResize);
70-
71-
// Cleanup
72-
return () => {
73-
window.removeEventListener("resize", debouncedHandleResize);
74-
// Cancel any pending debounced calls
75-
debouncedHandleResize.cancel();
76-
};
7754
}, [dispatch]);
7855

7956
return (

0 commit comments

Comments
 (0)