diff --git a/packages/slate-react/src/plugins/after.js b/packages/slate-react/src/plugins/after.js index 7c9953f45..fd5b09464 100644 --- a/packages/slate-react/src/plugins/after.js +++ b/packages/slate-react/src/plugins/after.js @@ -233,6 +233,15 @@ function AfterPlugin() { div.setAttribute('contenteditable', true) div.style.position = 'absolute' div.style.left = '-9999px' + + // COMPAT: In Firefox, the viewport jumps to find the phony div, so it + // should be created at the current scroll offset with `style.top`. + // The box model attributes which can interact with 'top' are also reset. + div.style.border = '0px' + div.style.padding = '0px' + div.style.margin = '0px' + div.style.top = `${window.pageYOffset || window.document.documentElement.scrollTop}px` + div.appendChild(contents) body.appendChild(div)