1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-30 18:39:51 +02:00
* fix: ts

* remove suggest
This commit is contained in:
Ziad Beyens
2019-12-07 21:33:59 +01:00
committed by Ian Storm Taylor
parent 3b16a1c3f0
commit 0e95b02399

View File

@@ -28,7 +28,6 @@ const MentionExample = () => {
const chars = CHARACTERS.filter(c =>
c.toLowerCase().startsWith(search.toLowerCase())
).slice(0, 10)
const suggest = target && chars.length > 0
const onKeyDown = useCallback(
event => {
@@ -62,14 +61,14 @@ const MentionExample = () => {
)
useEffect(() => {
if (suggest) {
if (target && chars.length > 0) {
const el = ref.current
const domRange = ReactEditor.toDOMRange(editor, target)
const rect = domRange.getBoundingClientRect()
el.style.top = `${rect.top + window.pageYOffset + 24}px`
el.style.left = `${rect.left + window.pageXOffset}px`
}
}, [index, search, target])
}, [chars.length, editor, index, search, target])
return (
<Slate
@@ -108,7 +107,7 @@ const MentionExample = () => {
onKeyDown={onKeyDown}
placeholder="Enter some text..."
/>
{suggest && (
{target && chars.length > 0 && (
<Portal>
<div
ref={ref}