bito-code-review[bot] commented on code in PR #44414:
URL: https://github.com/apache/superset/pull/44414#discussion_r4044144921
##########
superset-frontend/src/utils/downloadAsImage.tsx:
##########
@@ -159,7 +159,23 @@ const copyAllComputedStyles = (
}
};
-const processCloneForVisibility = (clone: HTMLElement) => {
+// True when the element clips its content on at least one axis.
`copyAllComputedStyles`
+// writes the computed `overflow` inline on the whole tree, so
`[style*="overflow"]` below
+// matches nearly every node; only the ones that actually clip should have
their overflow
+// rewritten. Both the shorthand and the longhands are read because engines
disagree on
+// which of them a computed style resolves: browsers resolve the longhands,
jsdom only
+// echoes back whichever form was specified.
+const clipsOverflow = (element: HTMLElement) => {
+ const computed = window.getComputedStyle(element);
+ return /auto|scroll|hidden|clip/.test(
+ `${computed.overflow} ${computed.overflowX} ${computed.overflowY}`,
+ );
+};
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>getComputedStyle in loop</b></div>
<div id="fix">
`clipsOverflow` calls `window.getComputedStyle(element)` for every node
matching the scrollable selectors — including `[style*="overflow"]`, which the
comment notes matches nearly every node. Each call forces a style/layout
recalc, adding O(n) forced layouts on the dashboard export path where the
previous code set overflow directly. Reuse the computed styles already cached
by `copyAllComputedStyles`.
</div>
</div>
<small><i>Code Review Run #2e3788</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]