Skip to content

Commit 8c0c3c2

Browse files
committed
🐛(frontend) fix selection click past end of content
On Chrome, when we click at the end of a line, the cursor is placed at the beginning of the line. We fix this behavior, now the cursor is placed at the end of the line.
1 parent c11d59c commit 8c0c3c2

File tree

5 files changed

+19
-11
lines changed

5 files changed

+19
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ and this project adheres to
2020
## Fixed
2121

2222
- 🐛(back) validate document content in serializer #822
23+
- 🐛(frontend) fix selection click past end of content #840
2324

2425
## [3.0.0] - 2025-03-28
2526

src/frontend/apps/e2e/__tests__/app-impress/config.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ test.describe('Config', () => {
134134
await createDoc(page, 'doc-ai-feature', browserName, 1);
135135

136136
await page.locator('.bn-block-outer').last().fill('Anything');
137-
await page.getByText('Anything').dblclick();
137+
await page.getByText('Anything').selectText();
138138
expect(
139139
await page.locator('button[data-test="convertMarkdown"]').count(),
140140
).toBe(1);

src/frontend/apps/e2e/__tests__/app-impress/doc-editor.spec.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ test.describe('Doc Editor', () => {
2525
await editor.click();
2626
await editor.fill('test content');
2727

28-
await editor.getByText('test content').dblclick();
28+
await editor
29+
.getByText('test content', {
30+
exact: true,
31+
})
32+
.selectText();
2933

3034
const toolbar = page.locator('.bn-formatting-toolbar');
3135
await expect(toolbar.locator('button[data-test="bold"]')).toBeVisible();
@@ -126,7 +130,7 @@ test.describe('Doc Editor', () => {
126130

127131
await expect(editor.getByText('[test markdown]')).toBeVisible();
128132

129-
await editor.getByText('[test markdown]').dblclick();
133+
await editor.getByText('[test markdown]').selectText();
130134
await page.locator('button[data-test="convertMarkdown"]').click();
131135

132136
await expect(editor.getByText('[test markdown]')).toBeHidden();
@@ -219,11 +223,8 @@ test.describe('Doc Editor', () => {
219223
await editor.fill('Hello World Doc persisted 2');
220224
await expect(editor.getByText('Hello World Doc persisted 2')).toBeVisible();
221225

222-
await page.goto('/');
223-
224-
await goToGridDoc(page, {
225-
title: doc,
226-
});
226+
const urlDoc = page.url();
227+
await page.goto(urlDoc);
227228

228229
await expect(editor.getByText('Hello World Doc persisted 2')).toBeVisible();
229230
});
@@ -297,7 +298,7 @@ test.describe('Doc Editor', () => {
297298
await page.locator('.bn-block-outer').last().fill('Hello World');
298299

299300
const editor = page.locator('.ProseMirror');
300-
await editor.getByText('Hello').dblclick();
301+
await editor.getByText('Hello').selectText();
301302

302303
await page.getByRole('button', { name: 'AI' }).click();
303304

@@ -380,7 +381,7 @@ test.describe('Doc Editor', () => {
380381
await page.locator('.bn-block-outer').last().fill('Hello World');
381382

382383
const editor = page.locator('.ProseMirror');
383-
await editor.getByText('Hello').dblclick();
384+
await editor.getByText('Hello').selectText();
384385

385386
/* eslint-disable playwright/no-conditional-expect */
386387
/* eslint-disable playwright/no-conditional-in-test */

src/frontend/apps/e2e/__tests__/app-impress/doc-search.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ test.describe('Document search', () => {
8686
const editor = page.locator('.ProseMirror');
8787
await editor.click();
8888
await editor.fill('Hello world');
89-
await editor.getByText('Hello world').dblclick();
89+
await editor.getByText('Hello world').selectText();
9090

9191
await page.keyboard.press('Control+k');
9292
await expect(page.getByRole('textbox', { name: 'Edit URL' })).toBeVisible();

src/frontend/apps/impress/src/features/docs/doc-editor/styles.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ export const cssEditor = (readonly: boolean) => css`
105105
padding: 2px;
106106
border-radius: 4px;
107107
}
108+
& .bn-inline-content {
109+
width: 100%;
110+
}
111+
.bn-block-content[data-content-type='checkListItem'] > div {
112+
width: 100%;
113+
}
108114
109115
@media screen and (width <= 768px) {
110116
& .bn-editor {

0 commit comments

Comments
 (0)