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

bug: getTabById or getState not work correctly #813

Closed
WheatMaThink opened this issue Oct 20, 2022 · 5 comments
Closed

bug: getTabById or getState not work correctly #813

WheatMaThink opened this issue Oct 20, 2022 · 5 comments
Labels
bug Something isn't working

Comments

@WheatMaThink
Copy link

WheatMaThink commented Oct 20, 2022

Describe the bug

如图所示,调用getTabById or getState函数,获取相对应的对象,但现在返回数值为: undefined。

是那里没有设置好吗?期待小伙伴的回复!小小吐槽一下,新版本的更新太慢了啊。

  • OS:
  • Browser: chrome
  • Molecule: 1.1.1

To reproduce

image

@WheatMaThink WheatMaThink added the bug Something isn't working label Oct 20, 2022
@wewoor
Copy link
Collaborator

wewoor commented Oct 20, 2022

Describe the bug

如图所示,调用getTabById or getState函数,获取相对应的对象,但现在返回数值为: undefined。

是那里没有设置好吗?期待小伙伴的回复!小小吐槽一下,新版本的更新太慢了啊。

  • OS:
  • Browser: chrome
  • Molecule: 1.1.1

To reproduce

image

谢谢反馈,反馈的问题都有在跟进的,新 feature 会比较慢

@wewoor wewoor changed the title bug: bug: getTabById or getState not work correctly Oct 20, 2022
@mortalYoung
Copy link
Collaborator

这里的逻辑是酱紫的:close button 触发关闭事件 -> 关闭事件触发 editorService.closeTab 事件把 tab 关闭 -> 触发 onCloseTab 事件
所以是先执行了 closeTab 把 tab 关闭了,然后用户才能监听到 onCloseTab 的回调函数
所以这里通过 getTabById 是拿不到 tab 的,因为此时该 tab 已经被关闭,所以相关实例已经被销毁了。
同时因为你当前 editor 中之后一个 tab,所以关闭后 current 就是 undefined 了

@WheatMaThink
Copy link
Author

谢谢两位的回复,刚刚学习TypeScript 几个月,有提问不当的地方,请包涵。

需求是:用户关闭tab 时,需要询问用户是否保存内容。根据逻辑触发事件后,才能扑捉到onCloseTab 事件,进行业务交互。

难道要重载closeTab函数,去看看.....

@mortalYoung
Copy link
Collaborator

目前还做不了 #737

@wewoor
Copy link
Collaborator

wewoor commented Oct 21, 2022

谢谢两位的回复,刚刚学习TypeScript 几个月,有提问不当的地方,请包涵。

需求是:用户关闭tab 时,需要询问用户是否保存内容。根据逻辑触发事件后,才能扑捉到onCloseTab 事件,进行业务交互。

难道要重载closeTab函数,去看看.....

我们刚刚合并了支持事件阻止的这个特性,可以关注下接下来发布的版本:#807

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants