mirror of
https://github.com/atom/atom.git
synced 2026-02-17 01:51:54 -05:00
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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user