Skip to content

fix: guard pixelsToPercentage against zero area#70

Merged
rijkvanzanten merged 1 commit into
mainfrom
fix-pixels-to-percentage
Feb 19, 2026
Merged

fix: guard pixelsToPercentage against zero area#70
rijkvanzanten merged 1 commit into
mainfrom
fix-pixels-to-percentage

Conversation

@HZooly
Copy link
Copy Markdown
Member

@HZooly HZooly commented Feb 19, 2026

Returns 0 when area is 0 instead of NaN/Infinity. This prevents invalid values during component mount before the container has been measured.

Copy link
Copy Markdown
Contributor

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 adds a guard to prevent division by zero in the pixelsToPercentage utility function. The fix prevents NaN or Infinity values from being returned during component mount when the container area is 0 (before measurement occurs).

Changes:

  • Added zero-area guard to pixelsToPercentage function to return 0 instead of NaN/Infinity
  • Added comprehensive test coverage for the edge case

Reviewed changes

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

File Description
packages/vue-split-panel/src/utils/pixels-to-percentage.ts Added ternary guard to return 0 when area is 0, preventing division by zero
packages/vue-split-panel/src/utils/pixels-to-percentage.test.ts Added test cases for zero area scenarios

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

@rijkvanzanten rijkvanzanten merged commit f6ed4b2 into main Feb 19, 2026
8 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.

3 participants