From 899d9a0a07566b55a2de2434266e4daeb4a65666 Mon Sep 17 00:00:00 2001 From: Pascal Mugnier Date: Tue, 8 May 2018 11:30:10 +0200 Subject: [PATCH] SONAR-10077 Right part navigation bar is inaccessible very small window --- .../src/main/js/components/nav/NavBar.tsx | 50 +++++++++++++++---- 1 file changed, 39 insertions(+), 11 deletions(-) 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 ( + + ); + } } -- 2.39.5