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

🐛S2Event.GLOBAL_CONTEXT_MENU 事件无法触发 #2687

Closed
1 of 5 tasks
XiChaoMing opened this issue Apr 28, 2024 · 5 comments · Fixed by #2690
Closed
1 of 5 tasks

🐛S2Event.GLOBAL_CONTEXT_MENU 事件无法触发 #2687

XiChaoMing opened this issue Apr 28, 2024 · 5 comments · Fixed by #2690
Assignees
Labels
🐛 bug 这个是一个 bug next 2.0-next 版本的问题 released on @next

Comments

@XiChaoMing
Copy link

🏷 Version

Package Version
@antv/s2 2.0.0-next.17

Sheet Type

  • PivotSheet
  • TableSheet
  • GridAnalysisSheet
  • StrategySheet
  • EditableSheet

🖋 Description

S2Event.GLOBAL_CONTEXT_MENU 事件进行了监听,在 Mac 触摸板上面进行右击操作,无法准确触发该事件的执行(在 Windows 上目前没问题)

🔗 Reproduce Link

  • 打开 官网案例
  • 在最下面的事件监听数组中添加 S2Event.GLOBAL_CONTEXT_MENU
  • 右击图表,偶尔会触发监听事件执行

😊 Expected Behavior

使用 Mac 触控板,右击事件可以准确执行

😅 Current Behavior

使用 Mac 触控板,右击事件无法准确执行

💻 System information

Environment Info
System Mac
Browser chrome: 122.0.6261.112(正式版本) (x86_64)
@XiChaoMing
Copy link
Author

不管 Windows 还是 Mac,好像都没法阻止默认的右键弹窗~

[
    S2Event.GLOBAL_SCROLL,
    S2Event.ROW_CELL_CLICK,
    S2Event.COL_CELL_CLICK,
    S2Event.CORNER_CELL_CLICK,
    S2Event.DATA_CELL_CLICK,
    S2Event.GLOBAL_SELECTED,
    S2Event.DATA_CELL_BRUSH_SELECTION,
    S2Event.LAYOUT_RESIZE,
    S2Event.GLOBAL_CONTEXT_MENU,
].forEach((eventName) => {
  s2.on(eventName, event => {
    if (eventName === S2Event.GLOBAL_CONTEXT_MENU) {
      // 没有效果
      event.preventDefault();
      event.stopPropagation();

      // 这样也没有效果
      event.originalEvent.preventDefault();
      event.originalEvent.stopPropagation();
    }
  });
});

@lijinke666
Copy link
Member

lijinke666 commented Apr 29, 2024

不管 Windows 还是 Mac,好像都没法阻止默认的右键弹窗~

[
    S2Event.GLOBAL_SCROLL,
    S2Event.ROW_CELL_CLICK,
    S2Event.COL_CELL_CLICK,
    S2Event.CORNER_CELL_CLICK,
    S2Event.DATA_CELL_CLICK,
    S2Event.GLOBAL_SELECTED,
    S2Event.DATA_CELL_BRUSH_SELECTION,
    S2Event.LAYOUT_RESIZE,
    S2Event.GLOBAL_CONTEXT_MENU,
].forEach((eventName) => {
  s2.on(eventName, event => {
    if (eventName === S2Event.GLOBAL_CONTEXT_MENU) {
      // 没有效果
      event.preventDefault();
      event.stopPropagation();

      // 这样也没有效果
      event.originalEvent.preventDefault();
      event.originalEvent.stopPropagation();
    }
  });
});

2.0 版本右键事件使用的 G 的 rightdown/rightup, 默认事件并不是右键菜单 (具体可以参考G 文档), 所以 preventDefault 无效, 需要这样写, 需要监听 <canvas/> DOM 元素, 后面补充下文档

s2.getCanvasElement().addEventListener('contextmenu', (event) => {
    event.preventDefault();
 });

@lijinke666 lijinke666 linked a pull request Apr 29, 2024 that will close this issue
5 tasks
@lijinke666 lijinke666 self-assigned this Apr 29, 2024
@lijinke666 lijinke666 added the 🐛 bug 这个是一个 bug label Apr 29, 2024
Copy link
Contributor

你好 @XiChaoMing,很抱歉给你带来了不好的体验, 我们会尽快排查问题并修复, 请关注后续发布日志.

Hello, @XiChaoMing, We are so sorry for the bad experience. We will troubleshoot and fix the problem as soon as possible. Please pay attention to the follow-up change logs.

@lijinke666 lijinke666 added the next 2.0-next 版本的问题 label Apr 30, 2024
@lijinke666
Copy link
Member

🎉 This issue has been resolved in version @antv/s2-v2.0.0-next.19 🎉

The release is available on:

Your semantic-release bot 📦🚀

@lijinke666
Copy link
Member

🎉 This issue has been resolved in version @antv/s2-react-v2.0.0-next.18 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug 这个是一个 bug next 2.0-next 版本的问题 released on @next
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants