This is an automated email from the ASF dual-hosted git repository. zqr10159 pushed a commit to branch 2.0.0 in repository https://gitbox.apache.org/repos/asf/hertzbeat.git
commit 7ff8e346850b33fbfbc9cba302c34ef423af7407 Author: Logic <[email protected]> AuthorDate: Sun May 31 10:37:07 2026 +0800 fix(web-next): clamp compact topology zoom after centering --- web-next/packages/hertzbeat-ui/src/topology-g6.test.tsx | 11 +++++++++++ web-next/packages/hertzbeat-ui/src/topology-g6.tsx | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/web-next/packages/hertzbeat-ui/src/topology-g6.test.tsx b/web-next/packages/hertzbeat-ui/src/topology-g6.test.tsx index b4f71a5d5f..7633ecdcdb 100644 --- a/web-next/packages/hertzbeat-ui/src/topology-g6.test.tsx +++ b/web-next/packages/hertzbeat-ui/src/topology-g6.test.tsx @@ -402,6 +402,17 @@ describe('@hertzbeat/ui topology G6 canvas', () => { expect(denseHtml).toContain('data-hz-topology-g6-initial-fit-strategy="overflow-fit"'); }); + it('keeps the compact center-only path ending with a hard 1x zoom clamp', () => { + const source = topologyG6Source; + const html = renderToStaticMarkup(<HzTopologyG6Canvas graph={buildHzTopologyG6ScaleFixture(7)} />); + const centerOnlyMatch = source.match(/async function centerOnlyG6Viewport[\s\S]*?\n}/); + + expect(html).toContain('data-hz-topology-g6-compact-final-zoom-clamp="true"'); + expect(centerOnlyMatch?.[0].indexOf('fitCenter')).toBeGreaterThanOrEqual(0); + expect(centerOnlyMatch?.[0].indexOf('zoomTo')).toBeGreaterThan(centerOnlyMatch?.[0].indexOf('fitCenter') ?? -1); + expect(centerOnlyMatch?.[0]).toContain('HZ_TOPOLOGY_G6_AUTO_FIT_MAX_ZOOM'); + }); + it('centers the shared G6 canvas after fit and reset view actions', () => { const source = topologyG6Source; const html = renderToStaticMarkup(<HzTopologyG6Canvas graph={buildHzTopologyG6ScaleFixture(8)} />); diff --git a/web-next/packages/hertzbeat-ui/src/topology-g6.tsx b/web-next/packages/hertzbeat-ui/src/topology-g6.tsx index 86e954234a..20ff1fbd1a 100644 --- a/web-next/packages/hertzbeat-ui/src/topology-g6.tsx +++ b/web-next/packages/hertzbeat-ui/src/topology-g6.tsx @@ -1163,8 +1163,8 @@ async function centerOnlyG6Viewport( animation: Record<string, unknown> | boolean ) { if (!runtimeGraph) return; - await runtimeGraph.zoomTo?.(HZ_TOPOLOGY_G6_AUTO_FIT_MAX_ZOOM, animation); await runtimeGraph.fitCenter?.(animation); + await runtimeGraph.zoomTo?.(HZ_TOPOLOGY_G6_AUTO_FIT_MAX_ZOOM, animation); } async function withG6AutoFitZoomRange(runtimeGraph: G6GraphRuntime, action: () => Promise<void>) { @@ -1890,6 +1890,7 @@ export function HzTopologyG6Canvas({ data-hz-topology-g6-auto-fit-zoom-range-owner="hertzbeat-ui-g6-auto-fit-zoom-range" data-hz-topology-g6-initial-fit-strategy={initialFitStrategy} data-hz-topology-g6-initial-fit-strategy-owner="hertzbeat-ui-g6-initial-fit-strategy" + data-hz-topology-g6-compact-final-zoom-clamp="true" data-hz-topology-g6-operator-zoom-bounds={`${HZ_TOPOLOGY_G6_MIN_ZOOM}-${HZ_TOPOLOGY_G6_MAX_ZOOM}`} data-hz-topology-g6-operator-zoom-growth="bounded-readable-nodes" data-hz-topology-g6-fit-mode="overflow-only-center" --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
