Skip to content

Commit

Permalink
Capture context menu events below the content
Browse files Browse the repository at this point in the history
FIX: Opening a context menu by clicking below the content element but inside
the editor now properly shows the browser's menu for editable elements.
  • Loading branch information
marijnh committed Mar 15, 2023
1 parent 46abe34 commit 733824d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,16 @@ export class InputState {
this.registeredEvents.push(type)
}
view.scrollDOM.addEventListener("mousedown", (event: MouseEvent) => {
if (event.target == view.scrollDOM && event.clientY > view.contentDOM.getBoundingClientRect().bottom)
if (event.target == view.scrollDOM && event.clientY > view.contentDOM.getBoundingClientRect().bottom) {
handleEvent(handlers.mousedown, event)
if (!event.defaultPrevented && event.button == 2) {
// Make sure the content covers the entire scroller height, in order
// to catch a native context menu click below it
let start = view.contentDOM.style.minHeight
view.contentDOM.style.minHeight = "100%"
setTimeout(() => view.contentDOM.style.minHeight = start, 200)
}
}
})
if (browser.chrome && browser.chrome_version == 102) { // FIXME remove at some point
// On Chrome 102, viewport updates somehow stop wheel-based
Expand Down

0 comments on commit 733824d

Please sign in to comment.