Skip to content

fix(behavior): use viewport filtering after the first render - #7682

Open
dvd233 wants to merge 1 commit into
antvis:v5from
dvd233:fix/7675-auto-adapt-label-viewport
Open

dvd233 wants to merge 1 commit into
antvis:v5from
dvd233:fix/7675-auto-adapt-label-viewport

Conversation

@dvd233

@dvd233 dvd233 commented Sep 18, 2026

Copy link
Copy Markdown

Summary

  • Clear AutoAdaptLabel's first-render guard after the initial full label scan.
  • Use viewport-filtered label candidates for subsequent transforms and redraws.
  • Add a regression test covering the post-render zoom path.

Why

isFirstRender was initialized to true but never reset, so getLabelElementsInView() was unreachable. Every later label recomputation therefore continued to sort and collision-check the full element map, even after the graph had been zoomed into a smaller viewport.

The initial full scan is preserved for first-render correctness; later updates now use the existing viewport-filtered path.

Fixes #7675

Validation

  • pnpm --filter @antv/g6 exec jest __tests__/unit/behaviors/auto-adapt-label.spec.ts --runInBand -t "uses viewport filtering after the first render" ✅
  • pnpm --filter @antv/g6 type-check ✅
  • pnpm --filter @antv/g6 lint ✅
  • git diff --check ✅

The complete existing auto-adapt-label.spec.ts suite still has four pre-existing SVG snapshot failures in this environment (expected: undefined, received: undefined); the new regression test passes. The snapshot failures reproduce on the unmodified baseline.

Codex was used to prepare the patch; the diff and validation results were reviewed before submission.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.46%. Comparing base (c4fc050) to head (86e81c1).
⚠️ Report is 2 commits behind head on v5.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##               v5    #7682      +/-   ##
==========================================
+ Coverage   94.43%   94.46%   +0.03%     
==========================================
  Files         188      188              
  Lines       10099    10100       +1     
  Branches     2201     2201              
==========================================
+ Hits         9537     9541       +4     
- Misses        516      559      +43     
+ Partials       46        0      -46     
Flag Coverage Δ
g6 94.46% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
packages/g6/src/behaviors/auto-adapt-label.ts 96.21% <100.00%> (+2.31%) ⬆️

... and 15 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch has not been deployed

No deployments
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.

AutoAdaptLabel.isFirstRender is never set to false, so getLabelElementsInView() has been unreachable since #6465

2 participants