From 3b80ac7b4e54941f49d19b3146f2dd52583a0b1c Mon Sep 17 00:00:00 2001 From: Anthony LC Date: Mon, 19 Jan 2026 16:50:20 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B(frontend)=20add=20fallback=20for?= =?UTF-8?q?=20unsupported=20blocknote=20languages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We had a bug when user selected a language that is not supported by BlockNote editor, the app would crash. If the language is not supported by BlockNote, we now fallback Blocknote editor to English. --- CHANGELOG.md | 1 + .../__tests__/app-impress/language.spec.ts | 25 ++++++++++++++++++- .../e2e/__tests__/app-impress/utils-common.ts | 4 +++ .../doc-editor/components/BlockNoteEditor.tsx | 5 +++- 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 07673931..c415e7b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to ### Fixed - ✅(e2e) fix e2e test for other browsers #1799 +- 🐛(frontend) add fallback for unsupported Blocknote languages #1810 ### Changed diff --git a/src/frontend/apps/e2e/__tests__/app-impress/language.spec.ts b/src/frontend/apps/e2e/__tests__/app-impress/language.spec.ts index 454763d7..27250623 100644 --- a/src/frontend/apps/e2e/__tests__/app-impress/language.spec.ts +++ b/src/frontend/apps/e2e/__tests__/app-impress/language.spec.ts @@ -1,6 +1,11 @@ import { expect, test } from '@playwright/test'; -import { TestLanguage, createDoc, waitForLanguageSwitch } from './utils-common'; +import { + TestLanguage, + createDoc, + overrideConfig, + waitForLanguageSwitch, +} from './utils-common'; import { openSuggestionMenu } from './utils-editor'; test.describe('Language', () => { @@ -107,6 +112,15 @@ test.describe('Language', () => { page, browserName, }) => { + await overrideConfig(page, { + LANGUAGES: [ + ['en-us', 'English'], + ['fr-fr', 'Français'], + ['sv-se', 'Svenska'], + ], + LANGUAGE_CODE: 'en-us', + }); + await createDoc(page, 'doc-toolbar', browserName, 1); const { editor, suggestionMenu } = await openSuggestionMenu({ page }); @@ -126,5 +140,14 @@ test.describe('Language', () => { await expect( suggestionMenu.getByText('Titres', { exact: true }), ).toBeVisible(); + + /** + * Swedish is not yet supported in the BlockNote locales, so it should fallback to English + */ + await waitForLanguageSwitch(page, TestLanguage.Swedish); + await openSuggestionMenu({ page }); + await expect( + suggestionMenu.getByText('Headings', { exact: true }), + ).toBeVisible(); }); }); diff --git a/src/frontend/apps/e2e/__tests__/app-impress/utils-common.ts b/src/frontend/apps/e2e/__tests__/app-impress/utils-common.ts index da4a722d..7b6bd2e7 100644 --- a/src/frontend/apps/e2e/__tests__/app-impress/utils-common.ts +++ b/src/frontend/apps/e2e/__tests__/app-impress/utils-common.ts @@ -330,6 +330,10 @@ export const TestLanguage = { label: 'Deutsch', expectedLocale: ['de-de'], }, + Swedish: { + label: 'Svenska', + expectedLocale: ['sv-se'], + }, } as const; type TestLanguageKey = keyof typeof TestLanguage; diff --git a/src/frontend/apps/impress/src/features/docs/doc-editor/components/BlockNoteEditor.tsx b/src/frontend/apps/impress/src/features/docs/doc-editor/components/BlockNoteEditor.tsx index 3b6b8b75..e0be2f28 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-editor/components/BlockNoteEditor.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-editor/components/BlockNoteEditor.tsx @@ -93,7 +93,10 @@ export const BlockNoteEditor = ({ doc, provider }: BlockNoteEditorProps) => { useSaveDoc(doc.id, provider.document, isConnectedToCollabServer); const { i18n } = useTranslation(); - const lang = i18n.resolvedLanguage; + let lang = i18n.resolvedLanguage; + if (!lang || !(lang in locales)) { + lang = 'en'; + } const { uploadFile, errorAttachment } = useUploadFile(doc.id);