@@ -285,9 +285,11 @@ class GameChooserDrawer extends Component {
285
285
return animation !== this . state . animation || show || show !== this . props . show
286
286
}
287
287
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
+ ) {
291
293
// Update scroll top
292
294
293
295
this . gamesListElement . scrollTop = this . state . scrollTop
@@ -304,6 +306,8 @@ class GameChooserDrawer extends Component {
304
306
if ( ! prevProps . show && this . props . show ) {
305
307
// Scroll current list element into view
306
308
309
+ await this . resize ( )
310
+
307
311
let index = this . shownGameTrees . findIndex ( ( [ , i ] ) => i === this . props . gameIndex )
308
312
let scrollTop = 0
309
313
if ( index >= 0 ) scrollTop = this . getRowFromIndex ( index ) * itemHeight
@@ -339,12 +343,14 @@ class GameChooserDrawer extends Component {
339
343
}
340
344
}
341
345
342
- resize ( ) {
346
+ async resize ( ) {
343
347
let innerWidth = this . gamesListElement . offsetWidth - 28
344
348
let height = this . gamesListElement . offsetHeight
345
349
let rowCount = Math . floor ( innerWidth / itemMinWidth )
346
350
347
- this . setState ( { innerWidth, height, rowCount} )
351
+ return new Promise ( resolve => {
352
+ this . setState ( { innerWidth, height, rowCount} , resolve )
353
+ } )
348
354
}
349
355
350
356
getRowFromIndex ( i ) {
0 commit comments