Skip to content

Instantly share code, notes, and snippets.

@kerrishotts
Created October 13, 2021 22:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kerrishotts/335e2413ccd6f3a710387e2f76468b2f to your computer and use it in GitHub Desktop.
Save kerrishotts/335e2413ccd6f3a710387e2f76468b2f to your computer and use it in GitHub Desktop.
Buggyfill for sp-textfield not firing `change` event
(function () {
if(require("uxp").versions.uxp.startsWith("uxp-5.5.1")) {
let curField, curValue;
document.addEventListener("focus", evt => {
curField = evt.target;
curValue = curField.value;
}, true);
document.addEventListener("blur", evt => {
if (evt.target.tagName === "SP-TEXTFIELD") {
if (curField === evt.target) {
if (curValue !== evt.target.value) {
const changeEvent = new Event("change", {
bubbles: true
});
evt.target.dispatchEvent(changeEvent);
}
}
}
}, true);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment