Skip to content

Commit

Permalink
[placeholder addon] Fix composition handling
Browse files Browse the repository at this point in the history
Issue #6422
  • Loading branch information
marijnh committed Sep 22, 2020
1 parent c74a1ca commit ca046d7
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions addon/display/placeholder.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,15 @@
}

function onComposition(cm) {
var empty = true, input = cm.getInputField()
if (input.nodeName == "TEXTAREA")
empty = !input.value
else if (cm.lineCount() == 1)
empty = !/[^\u200b]/.test(input.querySelector(".CodeMirror-line").textContent)
if (empty) clearPlaceholder(cm)
else setPlaceholder(cm)
setTimeout(function() {
var empty = false, input = cm.getInputField()
if (input.nodeName == "TEXTAREA")
empty = !input.value
else if (cm.lineCount() == 1)
empty = !/[^\u200b]/.test(input.querySelector(".CodeMirror-line").textContent)
if (empty) setPlaceholder(cm)
else clearPlaceholder(cm)
}, 20)
}

function onBlur(cm) {
Expand Down

0 comments on commit ca046d7

Please sign in to comment.