Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,16 @@ export function useIsHovered( {
// editability check can force a style recalculation, so it
// runs once the pointer rests, which also keeps the
// outline from flashing on blocks it merely passes over.
// The block's own element is only editable inside an
// editing host, and a press on it still drags the block.
// Mouse events target elements.
const target = event.target as HTMLElement;
timeoutId = setTimeout( () => {
node.classList.toggle(
'is-hovered-draggable',
! target.isContentEditable
! target.isContentEditable ||
( target === node &&
node.contentEditable === 'inherit' )
);
}, 100 );
}
Expand Down
33 changes: 33 additions & 0 deletions test/e2e/specs/editor/various/draggable-blocks.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,39 @@ test.describe( 'Draggable block', () => {
] );
} );

test( 'shows the hover outline on a block while the caret is in text (@firefox, @webkit)', async ( {
page,
editor,
} ) => {
await editor.insertBlock( {
name: 'core/paragraph',
attributes: { content: 'Text' },
} );
await editor.insertBlock( { name: 'core/separator' } );

// Move the caret from the selected separator into the paragraph.
await page.keyboard.press( 'ArrowUp' );
await expect(
editor.canvas.getByRole( 'textbox', { name: 'Editor canvas' } )
).toHaveCount( 1 );

const separator = editor.canvas.getByRole( 'document', {
name: 'Block: Separator',
} );
await separator.hover();
await expect
.poll( () =>
separator.evaluate(
( n ) =>
n.ownerDocument.defaultView.getComputedStyle(
n,
'::after'
).outlineStyle
)
)
.toBe( 'solid' );
} );

test( 'can drag a multi-selection by dragging inside a selected block', async ( {
editor,
page,
Expand Down
Loading