-
Notifications
You must be signed in to change notification settings - Fork 141
fix(mobile): cursor stays on archived thought after drag-to-archive #4405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| import { KnownDevices } from 'puppeteer' | ||
| import { ElementHandle } from 'puppeteer' | ||
| import { JSHandle } from 'puppeteer' | ||
| import type { WindowEm } from '../../../initialize' | ||
| import click from '../helpers/click' | ||
| import clickThought from '../helpers/clickThought' | ||
| import emulate from '../helpers/emulate' | ||
|
|
@@ -133,4 +134,33 @@ describe('DropGutter: mobile only', () => { | |
| expect(await isThoughtInDOM('b')).toBe(true) | ||
| expect(await isThoughtInDOM('c')).toBe(true) | ||
| }) | ||
|
|
||
| it('should move the cursor to the previous sibling when a thought is archived via DropGutter (#4077)', async () => { | ||
| await paste(` | ||
| - One | ||
| - Two | ||
| - Three | ||
| `) | ||
|
|
||
| await clickThought('Two') | ||
|
|
||
| await dragToDropGutter(await waitForEditable('Two')) | ||
|
|
||
| await waitForAlertContent('Removed 1 thought') | ||
|
|
||
| // Wait for the browser's asynchronous focus restoration to settle. This is what could override | ||
| // the cursor that archiveThought correctly placed on the previous sibling (#4077). | ||
| await new Promise(resolve => setTimeout(resolve, 1000)) | ||
|
|
||
| // The cursor should be placed on the previous sibling ("One"), not remain on the archived thought. | ||
| const cursorValue = await page.evaluate(() => { | ||
| const em = window.em as WindowEm | ||
| const cursor = em.testHelpers.getState().cursor | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed |
||
| if (!cursor) return null | ||
| const id = cursor[cursor.length - 1] | ||
| return em.getThoughtById(id)?.value ?? null | ||
| }) | ||
|
|
||
| expect(cursorValue).toBe('One') | ||
| }) | ||
| }) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem right to me. If hidden thoughts are shown, then we very well may want to set the cursor on the archived thought.
A better solution would be to prevent the spurious tap/focus event to begin with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaced the archived-path guard. The override actually came from a spurious post-drag focus on the now-hidden Editable, so
onFocusnow only sets the cursor whenisVisible. This prevents the spurious focus from re-cursoring without ever blocking archived thoughts: when hidden thoughts are shown,isVisibleis true and the cursor sets normally.