diff --git a/services/web/frontend/js/features/dictionary/components/dictionary-modal-content.tsx b/services/web/frontend/js/features/dictionary/components/dictionary-modal-content.tsx
index cd0af3cd77..4f86611eff 100644
--- a/services/web/frontend/js/features/dictionary/components/dictionary-modal-content.tsx
+++ b/services/web/frontend/js/features/dictionary/components/dictionary-modal-content.tsx
@@ -1,4 +1,4 @@
-import { useCallback } from 'react'
+import { useCallback, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { Alert, Button, Modal } from 'react-bootstrap'
import Icon from '../../../shared/components/icon'
@@ -18,19 +18,24 @@ export default function DictionaryModalContent({
handleHide,
}: DictionaryModalContentProps) {
const { t } = useTranslation()
+ const [learnedWords, setLearnedWords] = useState(ignoredWords.learnedWords)
const { isError, runAsync } = useAsync()
const handleRemove = useCallback(
word => {
- ignoredWords.remove(word)
runAsync(
postJSON('/spelling/unlearn', {
body: {
word,
},
})
- ).catch(debugConsole.error)
+ )
+ .then(() => {
+ ignoredWords.remove(word)
+ setLearnedWords(new Set(ignoredWords.learnedWords))
+ })
+ .catch(debugConsole.error)
},
[runAsync]
)
@@ -46,31 +51,29 @@ export default function DictionaryModalContent({
diff --git a/services/web/test/frontend/features/dictionary/components/dictionary-modal-content.test.jsx b/services/web/test/frontend/features/dictionary/components/dictionary-modal-content.test.jsx
index 072357dd83..6f1c637bba 100644
--- a/services/web/test/frontend/features/dictionary/components/dictionary-modal-content.test.jsx
+++ b/services/web/test/frontend/features/dictionary/components/dictionary-modal-content.test.jsx
@@ -1,5 +1,8 @@
-import { screen, fireEvent } from '@testing-library/react'
-import { expect } from 'chai'
+import {
+ screen,
+ fireEvent,
+ waitForElementToBeRemoved,
+} from '@testing-library/react'
import fetchMock from 'fetch-mock'
import DictionaryModal from '../../../../../frontend/js/features/dictionary/components/dictionary-modal'
import { renderWithEditorContext } from '../../../helpers/render-with-context'
@@ -16,6 +19,7 @@ describe('