Skip to content
Merged
Prev Previous commit
Next Next commit
[DevTools] Improve TraceUpdates popover behavior
  - Use manual popover mode to prevent closing with ESC key
  - Hide popover automatically when all trace updates expire
  - Remove focus styles and focus-related behaviors
  • Loading branch information
yongsk0066 committed Mar 17, 2025
commit a83589c485b4d4badbe48443c28e6db08638c776
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,23 @@ function drawNative(nodeToData: Map<HostInstance, Data>, agent: Agent) {
}

function drawWeb(nodeToData: Map<HostInstance, Data>) {
// if there are no nodes to draw, detach from top layer
if (nodeToData.size === 0) {
if (canvas !== null) {
try {
if (canvas.matches(':popover-open')) {
canvas.hidePopover();
}
} catch (e) {}
}
return;
}

if (canvas === null) {
initialize();
} else {
try {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above, you don't need it to wrap it in try / catch, since we bumped minimum versions for the extension

Please also check other calls below

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing this out! I've removed all try/catch blocks around Popover API calls.

if (canvas.hasAttribute('popover') && !canvas.matches(':popover-open')) {
if (!canvas.matches(':popover-open')) {
canvas.showPopover();
}
} catch (e) {}
Expand Down Expand Up @@ -197,11 +209,7 @@ function destroyNative(agent: Agent) {

function destroyWeb() {
if (canvas !== null) {
try {
if (canvas.hasAttribute('popover')) {
canvas.hidePopover();
}
} catch (e) {}
canvas.hidePopover();

if (canvas.parentNode != null) {
canvas.parentNode.removeChild(canvas);
Expand All @@ -216,7 +224,8 @@ export function destroy(agent: Agent): void {

function initialize(): void {
canvas = window.document.createElement('canvas');
canvas.setAttribute('popover', 'auto');
canvas.setAttribute('popover', 'manual');

canvas.style.cssText = `
xx-background-color: red;
xx-opacity: 0.5;
Expand All @@ -226,8 +235,10 @@ function initialize(): void {
position: fixed;
right: 0;
top: 0;
z-index: 1000000000;
background-color: transparent;
outline: none !important;
box-shadow: none !important;
border: none !important;
`;

const root = window.document.documentElement;
Expand Down