diff --git a/src/frontend/apps/e2e/__tests__/app-impress/doc-comments.spec.ts b/src/frontend/apps/e2e/__tests__/app-impress/doc-comments.spec.ts index cf5526f9..665a9f7a 100644 --- a/src/frontend/apps/e2e/__tests__/app-impress/doc-comments.spec.ts +++ b/src/frontend/apps/e2e/__tests__/app-impress/doc-comments.spec.ts @@ -394,6 +394,8 @@ test.describe('Doc Comments mobile', () => { await thread.getByRole('paragraph').first().fill('This is a comment'); await thread.locator('[data-test="save"]').click(); await expect(thread.getByText('This is a comment').first()).toBeHidden(); + // Check toolbar is closed after adding a comment + await expect(page.getByRole('button', { name: 'Paragraph' })).toBeHidden(); await editor.first().click(); await editor.getByText('Hello').click(); diff --git a/src/frontend/apps/impress/src/features/docs/doc-editor/components/comments/DocsThreadStore.tsx b/src/frontend/apps/impress/src/features/docs/doc-editor/components/comments/DocsThreadStore.tsx index 54b7fa4d..a8484ae8 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-editor/components/comments/DocsThreadStore.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-editor/components/comments/DocsThreadStore.tsx @@ -212,6 +212,17 @@ export class DocsThreadStore extends ThreadStore { .setMark?.('comment', { orphan: false, threadId }) .run?.(); + /** + * We have some issues with mobiles and the formatting toolbar reopening + * after adding a comment, so we restore the cursor position here. + * By restoring the cursor position at the head of the selection, + * it will automatically close the formatting toolbar. + */ + const cursorPos = editor._tiptapEditor?.state.selection.head; + if (cursorPos !== undefined) { + editor._tiptapEditor?.commands.setTextSelection(cursorPos); + } + return Promise.resolve(); }; @@ -241,6 +252,7 @@ export class DocsThreadStore extends ThreadStore { this.upsertClientThreadData(threadData); this.notifySubscribers(); this.ping(threadData.id); + return threadData; };