Skip to content

Commit f81e980

Browse files
committed
Introduce check for element that has getBoundlingClientRects
Fixes codesandbox#2197 Fixes codesandbox#2191 Fixes codesandbox#2193
1 parent 05a3183 commit f81e980

File tree

2 files changed

+10
-7
lines changed
  • packages/app/src/app

2 files changed

+10
-7
lines changed

packages/app/src/app/components/Preview/DevTools/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,11 @@ export default class DevTools extends React.PureComponent<Props, State> {
439439
return (
440440
<Container
441441
ref={el => {
442-
this.node = el;
443-
this.normalizeHeight(el);
442+
this.node = el || this.node;
443+
444+
if (this.node) {
445+
this.normalizeHeight(el);
446+
}
444447
}}
445448
style={{
446449
flex: primary

packages/app/src/app/pages/Sandbox/Editor/Content/Tabs/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,20 @@ import ModuleTab from './ModuleTab';
2121
class EditorTabs extends React.Component {
2222
componentDidUpdate(prevProps) {
2323
if (this.props.currentModuleId !== prevProps.currentModuleId) {
24+
const currentTab = this.tabEls[this.props.currentModuleId];
25+
2426
// We need to scroll to the tab
25-
if (this.tabEls[this.props.currentModuleId]) {
27+
if (currentTab && this.container) {
2628
const { width } = this.container.getBoundingClientRect();
2729
const scroll = this.container.scrollLeft;
28-
const { left } = this.tabEls[
29-
this.props.currentModuleId
30-
].getBoundingClientRect();
30+
const { left } = currentTab.getBoundingClientRect();
3131

3232
if (left > scroll && left < scroll + width) {
3333
// if it's already in view
3434
return;
3535
}
3636

37-
this.tabEls[this.props.currentModuleId].scrollIntoView(false);
37+
currentTab.scrollIntoView(false);
3838
}
3939
}
4040
}

0 commit comments

Comments
 (0)