From: Pascal Mugnier Date: Tue, 8 May 2018 09:30:10 +0000 (+0200) Subject: SONAR-10077 Right part navigation bar is inaccessible very small window X-Git-Tag: 7.5~1146 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=899d9a0a07566b55a2de2434266e4daeb4a65666;p=sonarqube.git SONAR-10077 Right part navigation bar is inaccessible very small window --- diff --git a/server/sonar-web/src/main/js/components/nav/NavBar.tsx b/server/sonar-web/src/main/js/components/nav/NavBar.tsx index b25d89ed302..f8ab495a622 100644 --- a/server/sonar-web/src/main/js/components/nav/NavBar.tsx +++ b/server/sonar-web/src/main/js/components/nav/NavBar.tsx @@ -19,6 +19,7 @@ */ import * as React from 'react'; import * as classNames from 'classnames'; +import { throttle } from 'lodash'; import './NavBar.css'; interface Props { @@ -29,15 +30,42 @@ interface Props { [prop: string]: any; } -export default function NavBar({ children, className, height, notif, ...other }: Props) { - return ( - - ); +interface State { + left: number; +} + +export default class NavBar extends React.PureComponent { + throttledFollowHorizontalScroll: (() => void); + + constructor(props: Props) { + super(props); + this.state = { left: 0 }; + this.throttledFollowHorizontalScroll = throttle(this.followHorizontalScroll, 10); + } + + componentDidMount() { + document.addEventListener('scroll', this.throttledFollowHorizontalScroll); + } + + componentWillUnmount() { + document.removeEventListener('scroll', this.throttledFollowHorizontalScroll); + } + + followHorizontalScroll = () => { + this.setState({ left: -document.documentElement.scrollLeft }); + }; + + render() { + const { children, className, height, notif, ...other } = this.props; + return ( + + ); + } }