Skip to content

Commit 47232df

Browse files
committed
Fix #559, but don't break GameChooserDrawer
1 parent 481d2c2 commit 47232df

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/components/drawers/GameChooserDrawer.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,11 @@ class GameChooserDrawer extends Component {
285285
return animation !== this.state.animation || show || show !== this.props.show
286286
}
287287

288-
componentDidUpdate(prevProps, prevState) {
289-
if (this.state.scrollTop !== prevState.scrollTop
290-
&& this.state.scrollTop !== this.gamesListElement.scrollTop) {
288+
async componentDidUpdate(prevProps, prevState) {
289+
if (
290+
this.state.scrollTop !== prevState.scrollTop
291+
&& this.state.scrollTop !== this.gamesListElement.scrollTop
292+
) {
291293
// Update scroll top
292294

293295
this.gamesListElement.scrollTop = this.state.scrollTop
@@ -304,6 +306,8 @@ class GameChooserDrawer extends Component {
304306
if (!prevProps.show && this.props.show) {
305307
// Scroll current list element into view
306308

309+
await this.resize()
310+
307311
let index = this.shownGameTrees.findIndex(([, i]) => i === this.props.gameIndex)
308312
let scrollTop = 0
309313
if (index >= 0) scrollTop = this.getRowFromIndex(index) * itemHeight
@@ -339,12 +343,14 @@ class GameChooserDrawer extends Component {
339343
}
340344
}
341345

342-
resize() {
346+
async resize() {
343347
let innerWidth = this.gamesListElement.offsetWidth - 28
344348
let height = this.gamesListElement.offsetHeight
345349
let rowCount = Math.floor(innerWidth / itemMinWidth)
346350

347-
this.setState({innerWidth, height, rowCount})
351+
return new Promise(resolve => {
352+
this.setState({innerWidth, height, rowCount}, resolve)
353+
})
348354
}
349355

350356
getRowFromIndex(i) {

style/index.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ header, #bar .bar {
748748
z-index: 15;
749749
}
750750
.drawer.hidecontent > * {
751-
visibility: hidden;
751+
display: none;
752752
}
753753
.drawer.show {
754754
transform: translateY(-285px);

0 commit comments

Comments
 (0)