[Glitch] Fix crash when switching back/from mobile layout
Port 91582937f3
to glitch-soc
Signed-off-by: Thibaut Girka <thib@sitedethib.com>
This commit is contained in:
parent
ef925f31a6
commit
c2112c7781
|
@ -41,7 +41,19 @@ export default class ColumnBackButton extends React.PureComponent {
|
||||||
if (multiColumn) {
|
if (multiColumn) {
|
||||||
return component;
|
return component;
|
||||||
} else {
|
} else {
|
||||||
return createPortal(component, document.getElementById('tabs-bar__portal'));
|
// The portal container and the component may be rendered to the DOM in
|
||||||
|
// the same React render pass, so the container might not be available at
|
||||||
|
// the time `render()` is called.
|
||||||
|
const container = document.getElementById('tabs-bar__portal');
|
||||||
|
if (container === null) {
|
||||||
|
// The container wasn't available, force a re-render so that the
|
||||||
|
// component can eventually be inserted in the container and not scroll
|
||||||
|
// with the rest of the area.
|
||||||
|
this.forceUpdate();
|
||||||
|
return component;
|
||||||
|
} else {
|
||||||
|
return createPortal(component, container);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -235,7 +235,19 @@ class ColumnHeader extends React.PureComponent {
|
||||||
if (multiColumn || placeholder) {
|
if (multiColumn || placeholder) {
|
||||||
return component;
|
return component;
|
||||||
} else {
|
} else {
|
||||||
return createPortal(component, document.getElementById('tabs-bar__portal'));
|
// The portal container and the component may be rendered to the DOM in
|
||||||
|
// the same React render pass, so the container might not be available at
|
||||||
|
// the time `render()` is called.
|
||||||
|
const container = document.getElementById('tabs-bar__portal');
|
||||||
|
if (container === null) {
|
||||||
|
// The container wasn't available, force a re-render so that the
|
||||||
|
// component can eventually be inserted in the container and not scroll
|
||||||
|
// with the rest of the area.
|
||||||
|
this.forceUpdate();
|
||||||
|
return component;
|
||||||
|
} else {
|
||||||
|
return createPortal(component, container);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue