Bug 1399265 - Avoid relayout when switching tab in devtools
MozReview-Commit-ID: J0vsN0MiN1o
--- a/devtools/client/shared/components/tabs/tabs.js
+++ b/devtools/client/shared/components/tabs/tabs.js
@@ -320,23 +320,22 @@ define(function (require, exports, modul
.map((tab, index) => {
let selected = selectedIndex === index;
if (renderOnlySelected && !selected) {
return null;
}
let id = tab.props.id;
- // Use 'visibility:hidden' + 'width/height:0' for hiding
- // content of non-selected tab. It's faster (not sure why)
- // than display:none and visibility:collapse.
+ // Use 'visibility:hidden' + 'height:0' for hiding content of non-selected
+ // tab. It's faster than 'display:none' because it avoids triggering frame
+ // destruction and reconstruction. 'width' is not changed to avoid relayout.
let style = {
visibility: selected ? "visible" : "hidden",
height: selected ? "100%" : "0",
- width: selected ? "100%" : "0",
};
// Allows lazy loading panels by creating them only if they are selected,
// then store a copy of the lazy created panel in `tab.panel`.
if (typeof tab.panel == "function" && selected) {
tab.panel = tab.panel(tab);
}
let panel = tab.panel || tab;