Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

调用graph.dispose时,注册的工具没有执行remove函数 #600

Closed
zaiMoe opened this issue Jan 27, 2021 · 2 comments
Closed

调用graph.dispose时,注册的工具没有执行remove函数 #600

zaiMoe opened this issue Jan 27, 2021 · 2 comments
Labels
released PR has released type: bug 缺陷 Defects and unexpected behaviors

Comments

@zaiMoe
Copy link

zaiMoe commented Jan 27, 2021

Expected Behavior

x6销毁的时候,能正常调用相关的钩子

Current Behavior

自定义工具,进行事件绑定,但销毁的时候,未执行remove钩子

class MyButton extends Button {
  isListenerClick = false;
  clicKCallback: () => void;

  onRender() {
    super.onRender();
    if (!this.isListenerClick) {
      this.clicKCallback = () => {
        let count = document.getElementById("count");
        count.value = +count.value + 1;
      };
      document.addEventListener("click", this.clicKCallback);
      this.isListenerClick = true;
    }
  }

  remove() { // dispose的时候不会调用
    document.removeEventListener("click", this.clicKCallback);
    return super.remove();
  }
}

https://codesandbox.io/s/cranky-cloud-m7xxc?file=/src/app.tsx

test2

Possible Solution

在调用dispose前线调用this.graph.clearCells();,但除了节点外,不知道其他的功能(滚动、画布等)是否也正常destroy

Steps To Reproduce

  1. ...
  2. ...
  3. ...
Error Message & Stack Trace

<!-- Provide a log message if relevant -->

Additional Context

Your Environment

  • x6: [e.g. 1.0.0]
  • OS: [e.g. macOS Sierra 10.12.3]
  • Browser: [e.g. chrome 78.0.3904.108]
@zaiMoe zaiMoe added the type: bug 缺陷 Defects and unexpected behaviors label Jan 27, 2021
@bubkoo bubkoo closed this as completed in e211c1a Jan 28, 2021
github-actions bot pushed a commit that referenced this issue Jan 29, 2021
## @antv/x6 [1.12.20](https://github.com/antvis/x6/compare/@antv/x6@1.12.19...@antv/x6@1.12.20) (2021-01-29)

### Bug Fixes

* 🐛 should clean cells on destroy graph ([e211c1a](e211c1a)), closes [#600](#600)
* change x6-svg-to-shape router ([3c5d11f](3c5d11f))
@x6-bot
Copy link
Contributor

x6-bot bot commented Jan 29, 2021

🎉 This issue has been resolved in the following release 🎉

Thanks for being a part of the AntV community! 💪💯

@x6-bot x6-bot bot added the released PR has released label Jan 29, 2021
@x6-bot
Copy link
Contributor

x6-bot bot commented Jan 30, 2022

This thread has been automatically locked because it has not had recent activity.

Please open a new issue for related bugs and link to relevant comments in this thread.

@x6-bot x6-bot bot locked as resolved and limited conversation to collaborators Jan 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
released PR has released type: bug 缺陷 Defects and unexpected behaviors
Projects
None yet
Development

No branches or pull requests

1 participant