Skip to content

Commit

Permalink
Give the content a min height again
Browse files Browse the repository at this point in the history
Hopefully avoid unnoticed widget height changes by requesting a measure on a no-op flush

FIX: Make the context menu work when clicking below the content in a fixed-height
editor.

Closes codemirror/dev#1277
  • Loading branch information
marijnh committed Oct 6, 2023
1 parent f6b9927 commit 44fa9ff
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 17 deletions.
5 changes: 4 additions & 1 deletion src/domobserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,10 @@ export class DOMObserver {
if (readSelection) this.readSelectionRange()

let domChange = this.readChange()
if (!domChange) return false
if (!domChange) {
this.view.requestMeasure()
return false
}
let startState = this.view.state
let handled = applyDOMChange(this.view, domChange)
// The view wasn't updated
Expand Down
16 changes: 0 additions & 16 deletions src/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,6 @@ export class InputState {

constructor(readonly view: EditorView) {
this.handleEvent = this.handleEvent.bind(this)
view.scrollDOM.addEventListener("mousedown", (event: MouseEvent) => {
if (event.target == view.scrollDOM && event.clientY > view.contentDOM.getBoundingClientRect().bottom) {
this.runHandlers("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)
}
}
})
view.scrollDOM.addEventListener("drop", (event: DragEvent) => {
if (event.target == view.scrollDOM && event.clientY > view.contentDOM.getBoundingClientRect().bottom)
this.runHandlers("drop", event)
})
this.notifiedFocused = view.hasFocus
// On Safari adding an input event handler somehow prevents an
// issue where the composition vanishes when you press enter.
Expand Down
1 change: 1 addition & 0 deletions src/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export const baseTheme = buildTheme("." + baseThemeID, {
whiteSpace: "pre",
wordWrap: "normal", // https://github.com/codemirror/dev/issues/456
boxSizing: "border-box",
minHeight: "100%",

padding: "4px 0",
outline: "none",
Expand Down

0 comments on commit 44fa9ff

Please sign in to comment.