diff --git a/src/main.tsx b/src/main.tsx index 4bca95c05..e3f18c844 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -2640,6 +2640,9 @@ class ScreenView extends React.Component<{screen : Screen}, {}> { @mobxReact.observer class ScreenTabs extends React.Component<{session : Session}, {}> { + tabsRef : React.RefObject = React.createRef(); + lastActiveScreenId : string = null; + @boundMethod handleNewScreen() { let {session} = this.props; @@ -2667,6 +2670,22 @@ class ScreenTabs extends React.Component<{session : Session}, {}> { console.log("handle context menu!", screenId); } + componentDidMount() : void { + this.componentDidUpdate(); + } + + componentDidUpdate() : void { + let {session} = this.props; + let activeScreenId = session.activeScreenId.get(); + if (activeScreenId != this.lastActiveScreenId && this.tabsRef.current) { + let tabElem = this.tabsRef.current.querySelector(sprintf(".screen-tab[data-screenid=\"%s\"]", activeScreenId)); + if (tabElem != null) { + tabElem.scrollIntoView(); + } + } + this.lastActiveScreenId = activeScreenId; + } + render() { let {session} = this.props; if (session == null) { @@ -2682,9 +2701,9 @@ class ScreenTabs extends React.Component<{session : Session}, {}> { } } return ( -
+
-
this.handleSwitchScreen(screen.screenId)} onContextMenu={(event) => this.handleContextMenu(event, screen.screenId)}> +
this.handleSwitchScreen(screen.screenId)} onContextMenu={(event) => this.handleContextMenu(event, screen.screenId)}> {screen.name.get()}
⌘{index+1}