-
-
Notifications
You must be signed in to change notification settings - Fork 571
fix(shell): recover a drop overlay that outlived its drag #1683
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6836114
fix(shell): recover a drop overlay that outlived its drag
giswqs be46aa1
Address review feedback
giswqs c44ba2c
Merge branch 'main' into fix/issue-1664-stuck-drop-overlay
giswqs 1899ca0
Merge branch 'main' into fix/issue-1664-stuck-drop-overlay
giswqs 6a695b8
Address review feedback
giswqs 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,65 @@ | ||
| import { expect, test, type Page } from "@playwright/test"; | ||
| import { waitForMap } from "./helpers"; | ||
|
|
||
| /** | ||
| * Regression cover for GeoLibre#1664: the drag-and-drop overlay could outlive | ||
| * its drag and sit over the map forever. | ||
| * | ||
| * The overlay is one boolean fed from two places — the webview drag handlers | ||
| * (balanced by a depth counter) and, on desktop, Tauri's native drag events (no | ||
| * counter). Either feed can strand it: a native "leave" the OS never delivers, | ||
| * or an unbalanced webview enter/leave pair that leaves the counter above zero. | ||
| * These tests strand it the second way, which is the one a browser can drive, | ||
| * and assert the recovery paths that clear it either way. | ||
| */ | ||
|
|
||
| const OVERLAY = '[data-testid="file-drop-overlay"]'; | ||
|
|
||
| /** Fires one file-drag event at the shell, without completing a drop. */ | ||
| async function fireFileDrag(page: Page, type: "dragenter" | "dragleave"): Promise<void> { | ||
| const dataTransfer = await page.evaluateHandle(() => { | ||
| const dt = new DataTransfer(); | ||
| dt.items.add(new File(["{}"], "style.json", { type: "application/json" })); | ||
| return dt; | ||
| }); | ||
| await page.dispatchEvent('[data-testid="map-canvas"]', type, { dataTransfer }); | ||
| await dataTransfer.dispose(); | ||
| } | ||
|
|
||
| /** | ||
| * Leaves the overlay showing with no drag in progress, by sending one more | ||
| * `dragenter` than `dragleave` — the shape a swallowed leave event produces. | ||
| */ | ||
| async function strandOverlay(page: Page): Promise<void> { | ||
| await fireFileDrag(page, "dragenter"); | ||
| await fireFileDrag(page, "dragenter"); | ||
| await fireFileDrag(page, "dragleave"); | ||
| await expect(page.locator(OVERLAY)).toBeVisible(); | ||
| } | ||
|
|
||
| test("Escape dismisses a drop overlay that outlived its drag", async ({ page }) => { | ||
| await waitForMap(page); | ||
| await strandOverlay(page); | ||
|
|
||
| await page.keyboard.press("Escape"); | ||
| await expect(page.locator(OVERLAY)).toBeHidden(); | ||
| }); | ||
|
|
||
| test("a pointer press dismisses a drop overlay that outlived its drag", async ({ page }) => { | ||
| await waitForMap(page); | ||
| await strandOverlay(page); | ||
|
|
||
| // A mouse button cannot go down during a real drag, so this is the signal | ||
| // that heals the overlay without the user knowing to press anything. | ||
| await page.mouse.click(400, 400); | ||
| await expect(page.locator(OVERLAY)).toBeHidden(); | ||
| }); | ||
|
|
||
| test("a balanced drag still shows and hides the overlay", async ({ page }) => { | ||
| await waitForMap(page); | ||
|
|
||
| await fireFileDrag(page, "dragenter"); | ||
| await expect(page.locator(OVERLAY)).toBeVisible(); | ||
| await fireFileDrag(page, "dragleave"); | ||
| await expect(page.locator(OVERLAY)).toBeHidden(); | ||
| }); | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.