Skip to content

[DevTools] Use Popover API for component inspect overlays #32703

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 @@ -40,9 +40,12 @@ class OverlayRect {
borderColor: overlayStyles.margin,
pointerEvents: 'none',
position: 'fixed',
backgroundColor: 'transparent',
outline: 'none',
boxShadow: 'none',
});

this.node.style.zIndex = '10000000';
this.node.setAttribute('popover', 'manual');

this.node.appendChild(this.border);
this.border.appendChild(this.padding);
Expand Down Expand Up @@ -105,8 +108,13 @@ class OverlayTip {
position: 'fixed',
fontSize: '12px',
whiteSpace: 'nowrap',
outline: 'none',
boxShadow: 'none',
border: 'none',
});

this.tip.setAttribute('popover', 'manual');

this.nameSpan = doc.createElement('span');
this.tip.appendChild(this.nameSpan);
assign(this.nameSpan.style, {
Expand All @@ -121,7 +129,6 @@ class OverlayTip {
color: '#d7d7d7',
});

this.tip.style.zIndex = '10000000';
container.appendChild(this.tip);
}

Expand Down Expand Up @@ -166,7 +173,6 @@ export default class Overlay {

const doc = currentWindow.document;
this.container = doc.createElement('div');
this.container.style.zIndex = '10000000';

this.tip = new OverlayTip(doc, this.container);
this.rects = [];
Expand Down Expand Up @@ -264,6 +270,20 @@ export default class Overlay {
width: this.tipBoundsWindow.innerWidth,
},
);

this.rects.forEach(rect => {
if (!rect.node.matches(':popover-open')) {
// $FlowFixMe[prop-missing]: Flow doesn't recognize Popover API
// $FlowFixMe[incompatible-use]: Flow doesn't recognize Popover API
rect.node.showPopover();
}
});

if (!this.tip.tip.matches(':popover-open')) {
// $FlowFixMe[prop-missing]: Flow doesn't recognize Popover API
// $FlowFixMe[incompatible-use]: Flow doesn't recognize Popover API
this.tip.tip.showPopover();
}
Comment on lines +274 to +286
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought hidePopover was unnecessary in this case because the element is completely removed from the DOM during the remove phase.

}
}

Expand Down
Loading