Skip to content

Update viewport adjustments to account for zoom level#519

Merged
mehmetozguldev merged 2 commits intoathasdev:masterfrom
malore350:view-zoom
Jan 27, 2026
Merged

Update viewport adjustments to account for zoom level#519
mehmetozguldev merged 2 commits intoathasdev:masterfrom
malore350:view-zoom

Conversation

@malore350
Copy link
Contributor

Pull Request

This PR corrects viewport dimensions and element positioning logic to properly account for the application's zoom level, ensuring the UI remains responsive and correctly bounded when zoomed in or out.

Description

  • Updated the main application container in App.tsx to set width and height dynamically (e.g., 100 / zoomLevel) to prevent layout overflow or under-fill when CSS zoom is applied.

  • Modified fit-viewport.ts to incorporate the current zoom level from zoom-store when calculating viewport boundaries.

  • Fixed positioning logic for UI elements to ensure they fit within the visible area regardless of the current scaling factor.

Related Issues

Fixes #516

Copilot AI review requested due to automatic review settings January 19, 2026 23:27
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR modifies viewport handling to account for the application's zoom level. When CSS zoom is applied to the main container, UI elements need adjusted boundary calculations to ensure they remain properly positioned and don't overflow the visible area.

Changes:

  • Modified the main application container to dynamically adjust dimensions inversely to zoom level, maintaining visual fill
  • Updated viewport boundary calculations to account for zoom when positioning UI elements

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/App.tsx Removed static h-screen/w-screen classes and added dynamic width/height styles that scale inversely with zoom level to maintain consistent visual rendering
src/utils/fit-viewport.ts Added zoom-aware viewport calculation by retrieving current zoom level and dividing viewport dimensions accordingly

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +94 to +95
width: `${100 / zoomLevel}vw`,
height: `${100 / zoomLevel}vh`,
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Division by zero risk: If zoomLevel is 0 (or very close to 0), this will cause division by zero or result in extremely large values. While the zoom store defines a minimum zoom level of 0.5, there's no runtime protection here. Consider adding a guard to ensure zoomLevel is a valid non-zero value before performing this calculation.

Copilot uses AI. Check for mistakes.
el: ElementBounds,
margin: number = MARGIN,
): { x: number; y: number } {
const zoomLevel = useZoomStore.getState().windowZoomLevel;
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Division by zero risk: If windowZoomLevel is 0, this will cause division by zero. While the zoom store defines a minimum zoom level of 0.5, there's no runtime protection here. Consider adding a guard to ensure zoomLevel is a valid non-zero value, or using Math.max(zoomLevel, 0.1) to provide a safe minimum.

Suggested change
const zoomLevel = useZoomStore.getState().windowZoomLevel;
const rawZoomLevel = useZoomStore.getState().windowZoomLevel;
const zoomLevel = Math.max(rawZoomLevel || 0, 0.1);

Copilot uses AI. Check for mistakes.
Comment on lines +28 to 32
const zoomLevel = useZoomStore.getState().windowZoomLevel;
const viewport = {
width: window.innerWidth,
height: window.innerHeight,
width: window.innerWidth / zoomLevel,
height: window.innerHeight / zoomLevel,
};
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential coordinate system issue with portaled elements: This function is used by components like dropdown.tsx and tooltip.tsx which portal their content to document.body (outside the zoomed container). When elements are portaled outside the zoom container, they should be positioned using normal viewport coordinates, not zoom-adjusted ones. Verify that dividing viewport dimensions by zoomLevel produces correct positioning for portaled elements, as getBoundingClientRect() returns coordinates that already account for CSS zoom transformations.

Copilot uses AI. Check for mistakes.
@mehmetozguldev mehmetozguldev self-requested a review January 20, 2026 13:49
@mehmetozguldev mehmetozguldev merged commit 2cb050e into athasdev:master Jan 27, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Zooming out blank area

2 participants

Comments