Skip to content

Conversation

@louisch
Copy link
Contributor

@louisch louisch commented Jul 17, 2025

Fixes a console.error that is emit when follow.zoom is turned on in the grid-line plugin

Reproduction sandbox for this bug here: https://stackblitz.com/edit/g6-v5-gridline-getcanvascenter-error?file=src%2FApp.tsx

The error happens because when getCanvasCenter is called, this.context.viewport may not be defined, so an error is thrown.

@hustcc hustcc requested review from Aarebecca and yvonneyx July 18, 2025 06:03
@hustcc
Copy link
Member

hustcc commented Jul 18, 2025

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request effectively addresses a console.error in the grid-line plugin that occurs when followZoom is enabled. The fix introduces a guard to prevent getCanvasCenter from being called before the viewport is initialized. A suggestion was made to make the implementation more robust by checking for both null and undefined values for the origin and using the nullish coalescing operator (??) for safer default value assignment.

@hustcc
Copy link
Member

hustcc commented Jul 29, 2025

@louisch 麻烦 pr 描述中来一个验证的截图或者 gif 吧

@Aarebecca Aarebecca merged commit 04920fa into antvis:v5 Aug 1, 2025
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.

3 participants