Ignore patches to content editable elements while focused (#247)

This commit is contained in:
Jonatan Kłosko 2021-04-28 19:11:19 +02:00 committed by GitHub
parent adb83eddc1
commit d3a2bfb60b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -32,6 +32,15 @@ const ContentEditable = {
this.el.blur();
}
});
// While the element is focused, ignore the incoming changes
this.el.addEventListener("focus", (event) => {
this.el.setAttribute("phx-update", "ignore");
});
this.el.addEventListener("blur", (event) => {
this.el.removeAttribute("phx-update");
});
},
updated() {