Skip to content
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

Fix:- Fixed dev tools inspect mode on Shadow dom #26888

Merged
merged 4 commits into from
Jun 7, 2023
Merged
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 @@ -46,7 +46,7 @@ export default function setupHighlighter(
window.addEventListener('mouseover', onMouseEvent, true);
window.addEventListener('mouseup', onMouseEvent, true);
window.addEventListener('pointerdown', onPointerDown, true);
window.addEventListener('pointerover', onPointerOver, true);
window.addEventListener('pointermove', onPointerMove, true);
window.addEventListener('pointerup', onPointerUp, true);
} else {
agent.emit('startInspectingNative');
Expand Down Expand Up @@ -74,7 +74,7 @@ export default function setupHighlighter(
window.removeEventListener('mouseover', onMouseEvent, true);
window.removeEventListener('mouseup', onMouseEvent, true);
window.removeEventListener('pointerdown', onPointerDown, true);
window.removeEventListener('pointerover', onPointerOver, true);
window.removeEventListener('pointermove', onPointerMove, true);
hoxyq marked this conversation as resolved.
Show resolved Hide resolved
window.removeEventListener('pointerup', onPointerUp, true);
} else {
agent.emit('stopInspectingNative');
Expand Down Expand Up @@ -151,14 +151,17 @@ export default function setupHighlighter(
event.preventDefault();
event.stopPropagation();

selectFiberForNode(((event.target: any): HTMLElement));
selectFiberForNode(getEventTarget(event));
}

function onPointerOver(event: MouseEvent) {
let lastHoveredNode: HTMLElement | null = null;
function onPointerMove(event: MouseEvent) {
event.preventDefault();
event.stopPropagation();

const target = ((event.target: any): HTMLElement);
const target: HTMLElement = getEventTarget(event);
if (lastHoveredNode === target) return;
lastHoveredNode = target;
hoxyq marked this conversation as resolved.
Show resolved Hide resolved

if (target.tagName === 'IFRAME') {
const iframe: HTMLIFrameElement = (target: any);
Expand Down Expand Up @@ -197,4 +200,12 @@ export default function setupHighlighter(
// because those are usually unintentional as you lift the cursor.
{leading: false},
);

function getEventTarget(event: MouseEvent): HTMLElement {
if (event.composed) {
return (event.composedPath()[0]: any);
}

hoxyq marked this conversation as resolved.
Show resolved Hide resolved
return (event.target: any);
}
}