diff options
author | Pascal Mugnier <pascal.mugnier@sonarsource.com> | 2018-05-08 11:30:10 +0200 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2018-05-24 20:20:47 +0200 |
commit | 899d9a0a07566b55a2de2434266e4daeb4a65666 (patch) | |
tree | 30a9f523cf848b5f35ca2ee3e5bd08549b8bb938 | |
parent | a03d7bccfb50673b56b4fde9370fa4a7ecd5c5b9 (diff) | |
download | sonarqube-899d9a0a07566b55a2de2434266e4daeb4a65666.tar.gz sonarqube-899d9a0a07566b55a2de2434266e4daeb4a65666.zip |
SONAR-10077 Right part navigation bar is inaccessible very small window
-rw-r--r-- | server/sonar-web/src/main/js/components/nav/NavBar.tsx | 50 |
1 files 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 ( - <nav {...other} className={classNames('navbar', className)} style={{ height }}> - <div - className={classNames('navbar-inner', { 'navbar-inner-with-notif': notif != null })} - style={{ height }}> - <div className="navbar-limited clearfix">{children}</div> - {notif} - </div> - </nav> - ); +interface State { + left: number; +} + +export default class NavBar extends React.PureComponent<Props, State> { + 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 ( + <nav {...other} className={classNames('navbar', className)} style={{ height }}> + <div + className={classNames('navbar-inner', { 'navbar-inner-with-notif': notif != null })} + style={{ height, left: this.state.left }}> + <div className="navbar-limited clearfix">{children}</div> + {notif} + </div> + </nav> + ); + } } |