1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-02-24 01:02:31 +01:00

fix: autoscroll when block is bigger than viewport (#3746)

* fix: autoscroll when block is bigger than viewport

* Create lazy-trains-sell.md

* Update lazy-trains-sell.md

* Update lazy-trains-sell.md

Co-authored-by: Tomás González <tgonzalez@asapp.com>
Co-authored-by: Ian Storm Taylor <ian@ianstormtaylor.com>
This commit is contained in:
Tomás González 2021-03-31 16:50:54 -03:00 committed by GitHub
parent 0473d0bf93
commit f8be509e4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View File

@ -0,0 +1,5 @@
---
'slate-react': patch
---
Fix editor auto-scrolling behavior when a block is bigger than the viewport.

View File

@ -204,10 +204,14 @@ export const Editable = (props: EditableProps) => {
)
}
const leafEl = newDomRange.startContainer.parentElement!
leafEl.getBoundingClientRect = newDomRange.getBoundingClientRect.bind(
newDomRange
)
scrollIntoView(leafEl, {
scrollMode: 'if-needed',
boundary: el,
})
delete leafEl.getBoundingClientRect
} else {
domSelection.removeAllRanges()
}