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

Using the middle button to close a tab triggers pasting on Linux #13395

Merged
merged 4 commits into from
Dec 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion app/src/layout/Wnd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,31 @@ export class Wnd {
window.siyuan.menus.menu.remove();
event.stopPropagation();
event.preventDefault();
const activeElement = document.activeElement;
const pasteHandler = (e: ClipboardEvent) => {
e.preventDefault();
e.stopPropagation();
};
window.addEventListener("paste", pasteHandler, {
capture: true,
once: true
});

// 如果在短时间内没有 paste 事件发生,移除监听
setTimeout(() => {
window.removeEventListener("paste", pasteHandler, {
capture: true
});
}, 250);

// 保持原有焦点
if (activeElement instanceof HTMLElement) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

activeElement 看上去和 document.activeElement 在这个事件内看上去都是同一个变量,我这里没有环境,不知道实际上的情况,还麻烦解释一下。

activeElement.focus();
}
break;
}
target = target.parentElement;
}

});
this.headersElement.addEventListener("mousewheel", (event: WheelEvent) => {
this.headersElement.scrollLeft = this.headersElement.scrollLeft + event.deltaY;
Expand Down
Loading