1
0
Fork 1
mirror of https://github.com/elk-zone/elk.git synced 2024-11-04 16:09:59 +00:00

feat: prevent page navigation when user select text (#203)

This commit is contained in:
花果山大圣 2022-11-29 00:31:09 +08:00 committed by GitHub
parent f72dd01ce7
commit c5afa9d579
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -24,7 +24,8 @@ const router = useRouter()
function onclick(evt: MouseEvent | KeyboardEvent) {
const path = evt.composedPath() as HTMLElement[]
const el = path.find(el => ['A', 'BUTTON', 'IMG', 'VIDEO'].includes(el.tagName?.toUpperCase()))
if (!el)
const text = window.getSelection()?.toString()
if (!el && !text)
go(evt)
}