Skip to content

Commit

Permalink
fix window init position
Browse files Browse the repository at this point in the history
  • Loading branch information
Dzuming committed Sep 13, 2024
1 parent 45e9151 commit a3d1570
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/components/window/WindowFrame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ export const WindowFrame = forwardRef((props: PropsWithChildren<WindowFrameProps
const contentAvailable = useContentVisibility(ref, onContentChanged);

const wasMaximized = usePreviousDifferent(maximized);
const previousPosition = usePreviousDifferent(position);

// setup position correction for screen edges
const calcEdgePosition = useCallback(
Expand All @@ -170,7 +171,7 @@ export const WindowFrame = forwardRef((props: PropsWithChildren<WindowFrameProps
);

useEffect(() => {
if (contentAvailable && position && !(maximized || wasMaximized)) {
if (!isEqual(previousPosition, position) && contentAvailable && position && !(maximized || wasMaximized)) {
const newValue = calcEdgePosition(viewport);
setPosition((current) => (isEqual(newValue, current) ? current : newValue));
}
Expand Down

0 comments on commit a3d1570

Please sign in to comment.