From 898a98a582aae964aea63f2c2cee5c0a8c8a2008 Mon Sep 17 00:00:00 2001 From: Pierre-Gilles Leymarie Date: Thu, 2 Sep 2021 16:45:30 +0800 Subject: [PATCH] Fix #1250: Dashboard should change fullscreen mode even when the change is triggered by the browser --- front/src/routes/dashboard/index.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/front/src/routes/dashboard/index.js b/front/src/routes/dashboard/index.js index df4c969395..c28c6b15f6 100644 --- a/front/src/routes/dashboard/index.js +++ b/front/src/routes/dashboard/index.js @@ -289,6 +289,11 @@ class Dashboard extends Component { } }; + onFullScreenChange = () => { + const isFullScreen = this.isFullScreen(); + this.props.setFullScreen(isFullScreen); + }; + constructor(props) { super(props); this.props = props; @@ -303,6 +308,9 @@ class Dashboard extends Component { componentDidMount() { this.init(); + document.addEventListener('fullscreenchange', this.onFullScreenChange, false); + document.addEventListener('webkitfullscreenchange', this.onFullScreenChange, false); + document.addEventListener('mozfullscreenchange', this.onFullScreenChange, false); } componentDidUpdate(prevProps) { @@ -311,6 +319,12 @@ class Dashboard extends Component { } } + componentWillUnmount() { + document.removeEventListener('fullscreenchange', this.onFullScreenChange, false); + document.removeEventListener('webkitfullscreenchange', this.onFullScreenChange, false); + document.removeEventListener('mozfullscreenchange', this.onFullScreenChange, false); + } + render( props, {