File tree Expand file tree Collapse file tree
app/javascript/mastodon/components Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -35,7 +35,19 @@ export default class ColumnBackButton extends React.PureComponent {
3535 if ( multiColumn ) {
3636 return component ;
3737 } else {
38- return createPortal ( component , document . getElementById ( 'tabs-bar__portal' ) ) ;
38+ // The portal container and the component may be rendered to the DOM in
39+ // the same React render pass, so the container might not be available at
40+ // the time `render()` is called.
41+ const container = document . getElementById ( 'tabs-bar__portal' ) ;
42+ if ( container === null ) {
43+ // The container wasn't available, force a re-render so that the
44+ // component can eventually be inserted in the container and not scroll
45+ // with the rest of the area.
46+ this . forceUpdate ( ) ;
47+ return component ;
48+ } else {
49+ return createPortal ( component , container ) ;
50+ }
3951 }
4052 }
4153
Original file line number Diff line number Diff line change @@ -178,7 +178,19 @@ class ColumnHeader extends React.PureComponent {
178178 if ( multiColumn || placeholder ) {
179179 return component ;
180180 } else {
181- return createPortal ( component , document . getElementById ( 'tabs-bar__portal' ) ) ;
181+ // The portal container and the component may be rendered to the DOM in
182+ // the same React render pass, so the container might not be available at
183+ // the time `render()` is called.
184+ const container = document . getElementById ( 'tabs-bar__portal' ) ;
185+ if ( container === null ) {
186+ // The container wasn't available, force a re-render so that the
187+ // component can eventually be inserted in the container and not scroll
188+ // with the rest of the area.
189+ this . forceUpdate ( ) ;
190+ return component ;
191+ } else {
192+ return createPortal ( component , container ) ;
193+ }
182194 }
183195 }
184196
You can’t perform that action at this time.
0 commit comments