From 0e95b0239972818ddbc5209ab225025c58f254ce Mon Sep 17 00:00:00 2001 From: Ziad Beyens Date: Sat, 7 Dec 2019 21:33:59 +0100 Subject: [PATCH] fix: ts (#3271) * fix: ts * remove suggest --- site/examples/mentions.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/site/examples/mentions.js b/site/examples/mentions.js index d42a4027a..8a1ab7729 100644 --- a/site/examples/mentions.js +++ b/site/examples/mentions.js @@ -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 ( { onKeyDown={onKeyDown} placeholder="Enter some text..." /> - {suggest && ( + {target && chars.length > 0 && (