-
Notifications
You must be signed in to change notification settings - Fork 121
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
Don't cancel gesture if touch is > 100 pixels away #2607
Open
ethan-james
wants to merge
5
commits into
cybersemics:main
Choose a base branch
from
ethan-james:ej-1705-disable-gestures-near-selection
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+97
−4
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
dbefbf1
getBoundingClientRect selection method
ethan-james a896fb9
Don't cancel gesture if touch is > 100 pixels away
ethan-james 0624e59
Add JSDoc to drawHorizontalLineGesture helper
ethan-james 003253f
Remove extraneous console.log
ethan-james 332c946
Test for drawing a gesture without a selection
ethan-james File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { KnownDevices } from 'puppeteer' | ||
import { drawHorizontalLineGesture } from '../helpers/gesture' | ||
import paste from '../helpers/paste' | ||
import { page } from '../setup' | ||
|
||
vi.setConfig({ testTimeout: 20000, hookTimeout: 20000 }) | ||
const iPhone = KnownDevices['iPhone 15 Pro'] | ||
|
||
describe('gestures', () => { | ||
it.skip('when starting a gesture, the command palette will open', async () => { | ||
const cursor = 'Hello' | ||
const importText = ` | ||
- ${cursor}` | ||
|
||
await page.emulate(iPhone) | ||
await paste(importText) | ||
|
||
await drawHorizontalLineGesture() | ||
|
||
// the command palette should open | ||
const popupValue = await page.$('[data-testid=popup-value]') | ||
expect(popupValue).toBeTruthy() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { page } from '../setup' | ||
|
||
/** Draw a gesture on the screen. */ | ||
const gesture = async (points: { x: number; y: number }[], complete: boolean = true) => { | ||
const start = points[0] | ||
|
||
await page.touchscreen.touchStart(start.x, start.y) | ||
|
||
for (let i = 1; i < points.length; i++) await page.touchscreen.touchMove(points[i].x, points[i].y) | ||
|
||
if (complete) await page.touchscreen.touchEnd() | ||
} | ||
|
||
export default gesture | ||
|
||
/** Draw a horizontal line gesture at a certain y coordinate on the touch screen. */ | ||
export const drawHorizontalLineGesture = (y: number = 100) => | ||
gesture( | ||
[ | ||
{ x: 100, y }, | ||
{ x: 110, y }, | ||
{ x: 120, y }, | ||
{ x: 130, y }, | ||
{ x: 140, y }, | ||
{ x: 150, y }, | ||
{ x: 160, y }, | ||
{ x: 170, y }, | ||
{ x: 180, y }, | ||
{ x: 190, y }, | ||
{ x: 200, y }, | ||
{ x: 210, y }, | ||
{ x: 220, y }, | ||
{ x: 230, y }, | ||
{ x: 240, y }, | ||
{ x: 250, y }, | ||
{ x: 260, y }, | ||
{ x: 270, y }, | ||
{ x: 280, y }, | ||
{ x: 290, y }, | ||
{ x: 300, y }, | ||
], | ||
false, | ||
) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@raineorshine @trevinhofmann I cannot for the life of me get puppeteer to simulate a selection while emulating a mobile browser. I'll give it another try on Monday, but please let me know if you have any experience getting it to work.
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.
Thanks for trying! If it's difficult/impossible I'm okay skimping on test coverage here.
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.
Did you try creating a selection with touch events, or by directly accessing the browser selection API?
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.
I did try directly accessing the browser selection API, and found that it wouldn't hold onto the selection once it left the
page.evaluate
block. That might be worth another try, but I didn't have much luck the first time.As for creating the selection with touch events, I tried to use a physical device to figure out how that would work, and it seemed like the only way to get a selection was to tap and then use the tooltip menu to "Select All". I don't think the tooltip menu appears in the Puppeteer emulator. If you know another, more reliable way to tap to create a a selection, please do let me know.
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.
A double tap selects the word under the touch. I imagine you will run into the same issue though in which the selection is lost after the
page.evaluate
.We will have to rely on manual testing for this one 👍