1- import { useContext , useState , useReducer } from 'react' ;
1+ import { useContext , useState } from 'react' ;
22import PropTypes from 'prop-types' ;
33import {
44 Button ,
@@ -79,7 +79,6 @@ export function CollectionDialog({
7979} ) {
8080 const container = useContext ( WorkspaceContext ) ;
8181 const [ filter , setFilter ] = useState ( null ) ;
82- const [ , forceUpdate ] = useReducer ( x => x + 1 , 0 ) ;
8382
8483 /** */
8584 const hideDialog = ( ) => {
@@ -115,18 +114,14 @@ export function CollectionDialog({
115114 } ;
116115
117116 /** */
118- const dialogContainer = ( ) => ( container ?. current || document . body ) . querySelector ( `#${ windowId } ` ) ;
117+ const dialogContainer = ( container ?. current || document . body ) . querySelector ( `#${ windowId } ` ) ;
119118
120119 if ( error ) return null ;
121- // If this component is optimistically rendering ahead of the window its in
122- // force a re-render so that it is placed correctly. The right thing here is
123- // to maybe pass a ref.
124- if ( ! dialogContainer ( ) ) {
125- forceUpdate ( ) ;
120+ if ( ! dialogContainer ) {
126121 return null ;
127122 }
128123
129- if ( ! ready ) return < Placeholder container = { dialogContainer ( ) } onClose = { hideDialog } /> ;
124+ if ( ! ready ) return < Placeholder container = { dialogContainer } onClose = { hideDialog } /> ;
130125
131126 const rights = manifest && ( asArray ( manifest . getProperty ( 'rights' ) || manifest . getProperty ( 'license' ) ) ) ;
132127
@@ -144,7 +139,7 @@ export function CollectionDialog({
144139 < Dialog
145140 variant = "contained"
146141 onClose = { hideDialog }
147- container = { dialogContainer ( ) }
142+ container = { dialogContainer }
148143 open
149144 >
150145 < DialogTitle id = "select-collection" >
0 commit comments