Skip to content

Commit dcda006

Browse files
committed
[DevTools] Fix Flow type errors for TraceUpdates popover implementation
Added $FlowFixMe annotations to address Flow type errors with the Popover API: - prop-missing: Added annotations for Popover API methods (showPopover, hidePopover) that Flow doesn't yet recognize in HTMLCanvasElement - incompatible-use: Fixed type errors related to null checking and property access Flow doesn't have built-in types for the new Popover API yet, so we need to tell it to ignore these specific errors while maintaining type safety for the rest of the codebase.
1 parent a83589c commit dcda006

File tree

1 file changed

+15
-4
lines changed
  • packages/react-devtools-shared/src/backend/views/TraceUpdates

1 file changed

+15
-4
lines changed

packages/react-devtools-shared/src/backend/views/TraceUpdates/canvas.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const COLORS = [
2828
'#febc38',
2929
];
3030

31+
// $FlowFixMe[prop-missing] - Flow doesn't know about Popover API methods
3132
let canvas: HTMLCanvasElement | null = null;
3233

3334
function drawNative(nodeToData: Map<HostInstance, Data>, agent: Agent) {
@@ -47,7 +48,9 @@ function drawWeb(nodeToData: Map<HostInstance, Data>) {
4748
if (nodeToData.size === 0) {
4849
if (canvas !== null) {
4950
try {
51+
// $FlowFixMe[incompatible-use] - Flow doesn't know about Popover API
5052
if (canvas.matches(':popover-open')) {
53+
// $FlowFixMe[prop-missing]
5154
canvas.hidePopover();
5255
}
5356
} catch (e) {}
@@ -59,7 +62,9 @@ function drawWeb(nodeToData: Map<HostInstance, Data>) {
5962
initialize();
6063
} else {
6164
try {
65+
// $FlowFixMe[incompatible-use]
6266
if (!canvas.matches(':popover-open')) {
67+
// $FlowFixMe[prop-missing]
6368
canvas.showPopover();
6469
}
6570
} catch (e) {}
@@ -209,8 +214,12 @@ function destroyNative(agent: Agent) {
209214

210215
function destroyWeb() {
211216
if (canvas !== null) {
212-
canvas.hidePopover();
217+
try {
218+
// $FlowFixMe[prop-missing]
219+
canvas.hidePopover();
220+
} catch (e) {}
213221

222+
// $FlowFixMe[incompatible-use]
214223
if (canvas.parentNode != null) {
215224
canvas.parentNode.removeChild(canvas);
216225
}
@@ -226,6 +235,7 @@ function initialize(): void {
226235
canvas = window.document.createElement('canvas');
227236
canvas.setAttribute('popover', 'manual');
228237

238+
// $FlowFixMe[incompatible-use]
229239
canvas.style.cssText = `
230240
xx-background-color: red;
231241
xx-opacity: 0.5;
@@ -236,15 +246,16 @@ function initialize(): void {
236246
right: 0;
237247
top: 0;
238248
background-color: transparent;
239-
outline: none !important;
240-
box-shadow: none !important;
241-
border: none !important;
249+
outline: none;
250+
box-shadow: none;
251+
border: none;
242252
`;
243253

244254
const root = window.document.documentElement;
245255
root.insertBefore(canvas, root.firstChild);
246256

247257
try {
258+
// $FlowFixMe[prop-missing]
248259
canvas.showPopover();
249260
} catch (e) {}
250261
}

0 commit comments

Comments
 (0)