molecule icon indicating copy to clipboard operation
molecule copied to clipboard

bug: can't prevent default behavior about close tab

Open mortalYoung opened this issue 2 years ago • 2 comments

Describe the bug

refer to: https://github.com/DTStack/Taier/issues/459

I need a confirm before close, but no matter editor.onClose or something else, it all can't prevent close.

Versions

  • OS: MacOS
  • Browser: chrome
  • Molecule: 0.9.0-beta.4.2

To reproduce

Expected

I can have a confirm to prevent close by some way.

Actually happening

mortalYoung avatar May 18 '22 06:05 mortalYoung

  1. VIew层触发了closeTab方法,会执行 EditorControlleronCloseTab,这里面主要是调用editorServicecloseTab关闭tab以及emit一个closeTab的行为供用户监听

  2. 用户想在closeTab之前增加二次弹窗,可以自定义EditorControlleronCloseTab行为

  modal.show();  // 自定义逻辑
  this.editorService.closeTab(tabId, groupId);
  this.emit(EditorEvent.OnCloseTab, tabId, groupId);

目前内置的extensions主要是考虑Molecule Web主界面的UI交互,Editor部分大部分的actions都会遇到增加二次确认的场景,因此用户有特殊需求。可以定制controller行为即可, 或者采用自己的controller

关于closeTab 内置行为主要是closeTab。其他的都交给用户了,把这部分从extensions剔除掉也不合适

@mortalYoung

mumiao avatar Jul 11 '22 06:07 mumiao

评估了一下有破坏性变更,放到下个 minor 版本做

mortalYoung avatar Jul 12 '22 03:07 mortalYoung