Ignore clicks on block decorations

Previously, clicking on a block decoration to interact with it would
cause the editor to scroll to the line next to it. This is inconvenient,
especially if the decoration was designed to be interactive and
contained buttons or links. If the decoration was close to the bottom of
the screen, clicking on a button inside of it would make the editor
scroll down and abort the click.

This behavior regressed during the editor rendering layer rewrite and
with this commit we are restoring the original behavior by simply
ignoring clicks that land on block decorations.
This commit is contained in:
Antonio Scandurra
2017-08-14 15:43:48 +02:00
parent 44441b14c3
commit eb1eeb3fde
2 changed files with 45 additions and 0 deletions

View File

@@ -1689,6 +1689,18 @@ class TextEditorComponent {
const {target, button, detail, ctrlKey, shiftKey, metaKey} = event
const platform = this.getPlatform()
// Ignore clicks on block decorations.
if (target) {
let element = target
while (element && element !== this.element) {
if (this.blockDecorationsByElement.has(element)) {
return
}
element = element.parentElement
}
}
// On Linux, position the cursor on middle mouse button click. A
// textInput event with the contents of the selection clipboard will be
// dispatched by the browser automatically on mouseup.