Skip to content

Commit

Permalink
Selection: restore focus after dragging out of the block repeatedly (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Aug 9, 2023
1 parent da06123 commit 0ebcee8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ export default function useDragSelection() {
return;
}

anchorElement = ownerDocument.activeElement;
// Do not rely on the active element because it may change after
// the mouse leaves for the first time. See
// https://github.com/WordPress/gutenberg/issues/48747.
anchorElement = target;

startMultiSelect();

// `onSelectionStart` is called after `mousedown` and
Expand Down
4 changes: 4 additions & 0 deletions test/e2e/specs/editor/various/multi-block-selection.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,10 @@ test.describe( 'Multi-block selection', () => {
await page.mouse.click( coord1.x, coord1.y );
await page.mouse.down();
await page.mouse.move( coord2.x, coord2.y, { steps: 10 } );
// Simulate moving once in and out of the paragraph.
// Fixes https://github.com/WordPress/gutenberg/issues/48747.
await page.mouse.move( coord1.x, coord1.y, { steps: 10 } );
await page.mouse.move( coord2.x, coord2.y, { steps: 10 } );
await page.mouse.up();

// Wait for:
Expand Down

1 comment on commit 0ebcee8

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 0ebcee8.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5806303694
📝 Reported issues:

Please sign in to comment.