icestark icon indicating copy to clipboard operation
icestark copied to clipboard

[QUSTION]AppLink可以支持中键/command打开新窗口吗?

Open xmsz opened this issue 3 years ago • 2 comments

Do you want to request a feature or report a bug?

What is the current behavior?

背景

<AppLink to="/a">a</AppLink>
  • 预期是可以通过鼠标中键或者command加点击实现新窗口打开,但是现在不行,只能当前页面跳转
  • Link和普通的a标签反倒可以

我的场景是菜单栏,用户希望鼠标中键新窗口打开,这样可以快捷同时打开多个。

**If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.

What is the expected behavior?

xmsz avatar Nov 18 '22 11:11 xmsz

我理解本来就可以吧

maoxiaoke avatar Nov 22 '22 13:11 maoxiaoke

我理解本来就可以吧

对 Reac-router的Link,默认是支持的

type LimitedMouseEvent = Pick<
  MouseEvent,
  'button' | 'metaKey' | 'altKey' | 'ctrlKey' | 'shiftKey'
>;
function isModifiedEvent(event: LimitedMouseEvent) {
  return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
}
function shouldProcessLinkClick(event: LimitedMouseEvent, target?: string) {
  return (
    event.button === 0 && // Ignore everything but left clicks
    (!target || target === '_self') && // Let browser handle "target=_blank" etc.
    !isModifiedEvent(event) // Ignore clicks with modifier keys
  );
}

icestark的AppLink应该是全部拦截掉了

xmsz avatar Nov 22 '22 13:11 xmsz