Skip to content

fix: 补充 shape destroy逻辑 - #336

Merged
tangying1027 merged 1 commit into
antvis:masterfrom
huaxiabuluo:fix-basic-shape-update
Jul 30, 2025
Merged

fix: 补充 shape destroy逻辑#336
tangying1027 merged 1 commit into
antvis:masterfrom
huaxiabuluo:fix-basic-shape-update

Conversation

@huaxiabuluo

@huaxiabuluo huaxiabuluo commented Jul 24, 2025

Copy link
Copy Markdown
Contributor

Canvas 的实例调用 render 方法完成首次渲染后,再次执行 update 方法更新画布,如果使用了 line | circle | rect | ... 等基础图形标签,会导致上一屏的基础图形不会被正确擦除。

对于下面测试用例:

const context = createContext();
const { props } = (
  <Canvas context={context}>
    <rect
      style={{
        width: 36,
        height: 36,
        fill: 'red',
      }}
    />
  </Canvas>
);

const canvas = new Canvas(props);
await canvas.render();

const { props: nextProps } = (
  <Canvas context={context}>
    <circle
      style={{
        cx: 80,
        cy: 30,
        r: 20,
        lineWidth: 2,
        stroke: '#e45649',
        fill: 'blue',
      }}
    />
  </Canvas>
);
await delay(500);
await canvas.update(nextProps);

await delay(200);
expect(context).toMatchImageSnapshot();
  • Before (update 渲染异常, rect 没有销毁擦除)
vnode-update-test-tsx-vnode-更新-基础图形更新-1-snap
  • After (update 渲染正常, rect 被销毁擦除)
vnode-update-test-tsx-vnode-更新-基础图形更新-1-snap

@tangying1027 tangying1027 changed the title fix: basic shapes update fix: 补充 shape destroy逻辑 Jul 30, 2025
@tangying1027
tangying1027 merged commit 1e0211b into antvis:master Jul 30, 2025
1 of 2 checks passed
tangying1027 added a commit that referenced this pull request Jul 30, 2025
tangying1027 added a commit that referenced this pull request Jul 31, 2025
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.

2 participants