diff --git a/src/components/spellchecker/SpellChecker.tsx b/src/components/spellchecker/SpellChecker.tsx index 196639d7e..314982e0d 100644 --- a/src/components/spellchecker/SpellChecker.tsx +++ b/src/components/spellchecker/SpellChecker.tsx @@ -85,11 +85,15 @@ const SpellCheckForm = ({ setSuggestions(data); renderHighlightedText(text, data); setError(null); + setSelectedWord(null); + setSuggestionPosition(null); spellcheckResult.current = null; setLoading(false); } catch (error) { if (!axios.isCancel(error)) { setSuggestions([]); + setSelectedWord(null); + setSuggestionPosition(null); setError(error as Error); setLoading(false); } @@ -274,19 +278,19 @@ const SpellCheckForm = ({ - {selectedWord && suggestionPosition && ( + {selectedWord && suggestionPosition && suggestions.some((s) => s.token === selectedWord && s.sugg.length > 0) && (
{suggestions .find((s) => s.token === selectedWord) - ?.sugg.map((suggestion, index) => ( + ?.sugg?.map((suggestion, index) => (
applySuggestion(suggestion)} - onKeyDown={(event) => { + onKeyDown={(event: React.KeyboardEvent) => { if (event.key === 'Enter') { applySuggestion(suggestion); }