mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-02-24 09:13:24 +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:
parent
0473d0bf93
commit
f8be509e4d
5
.changeset/lazy-trains-sell.md
Normal file
5
.changeset/lazy-trains-sell.md
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'slate-react': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix editor auto-scrolling behavior when a block is bigger than the viewport.
|
@ -204,10 +204,14 @@ export const Editable = (props: EditableProps) => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
const leafEl = newDomRange.startContainer.parentElement!
|
const leafEl = newDomRange.startContainer.parentElement!
|
||||||
|
leafEl.getBoundingClientRect = newDomRange.getBoundingClientRect.bind(
|
||||||
|
newDomRange
|
||||||
|
)
|
||||||
scrollIntoView(leafEl, {
|
scrollIntoView(leafEl, {
|
||||||
scrollMode: 'if-needed',
|
scrollMode: 'if-needed',
|
||||||
boundary: el,
|
boundary: el,
|
||||||
})
|
})
|
||||||
|
delete leafEl.getBoundingClientRect
|
||||||
} else {
|
} else {
|
||||||
domSelection.removeAllRanges()
|
domSelection.removeAllRanges()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user