Skip to content

Commit 3e283e3

Browse files
committed
[DevTools] Use Popover API for component highlighting overlays
Enhance the Components tab's element highlighting feature to use the Popover API for top layer rendering. This ensures highlight overlays always appear above other content including dialogs, tooltips, and other top layer elements.
1 parent f3c9560 commit 3e283e3

File tree

1 file changed

+23
-3
lines changed
  • packages/react-devtools-shared/src/backend/views/Highlighter

1 file changed

+23
-3
lines changed

packages/react-devtools-shared/src/backend/views/Highlighter/Overlay.js

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,12 @@ class OverlayRect {
4040
borderColor: overlayStyles.margin,
4141
pointerEvents: 'none',
4242
position: 'fixed',
43+
backgroundColor: 'transparent',
44+
outline: 'none',
45+
boxShadow: 'none',
4346
});
4447

45-
this.node.style.zIndex = '10000000';
48+
this.node.setAttribute('popover', 'manual');
4649

4750
this.node.appendChild(this.border);
4851
this.border.appendChild(this.padding);
@@ -105,8 +108,13 @@ class OverlayTip {
105108
position: 'fixed',
106109
fontSize: '12px',
107110
whiteSpace: 'nowrap',
111+
outline: 'none',
112+
boxShadow: 'none',
113+
border: 'none',
108114
});
109115

116+
this.tip.setAttribute('popover', 'manual');
117+
110118
this.nameSpan = doc.createElement('span');
111119
this.tip.appendChild(this.nameSpan);
112120
assign(this.nameSpan.style, {
@@ -121,7 +129,6 @@ class OverlayTip {
121129
color: '#d7d7d7',
122130
});
123131

124-
this.tip.style.zIndex = '10000000';
125132
container.appendChild(this.tip);
126133
}
127134

@@ -166,7 +173,6 @@ export default class Overlay {
166173

167174
const doc = currentWindow.document;
168175
this.container = doc.createElement('div');
169-
this.container.style.zIndex = '10000000';
170176

171177
this.tip = new OverlayTip(doc, this.container);
172178
this.rects = [];
@@ -264,6 +270,20 @@ export default class Overlay {
264270
width: this.tipBoundsWindow.innerWidth,
265271
},
266272
);
273+
274+
this.rects.forEach(rect => {
275+
if (!rect.node.matches(':popover-open')) {
276+
// $FlowFixMe[prop-missing]: Flow doesn't recognize Popover API
277+
// $FlowFixMe[incompatible-use]: Flow doesn't recognize Popover API
278+
rect.node.showPopover();
279+
}
280+
});
281+
282+
if (!this.tip.tip.matches(':popover-open')) {
283+
// $FlowFixMe[prop-missing]: Flow doesn't recognize Popover API
284+
// $FlowFixMe[incompatible-use]: Flow doesn't recognize Popover API
285+
this.tip.tip.showPopover();
286+
}
267287
}
268288
}
269289

0 commit comments

Comments
 (0)