@@ -28,12 +28,20 @@ export class WorkspaceAdd extends Component {
2828 constructor ( props ) {
2929 super ( props ) ;
3030
31- this . state = { addResourcesOpen : false } ;
3231 this . ref = createRef ( ) ;
32+ this . state = { addResourcesOpen : false , refWidth : '100%' } ;
3333
3434 this . onSubmit = this . onSubmit . bind ( this ) ;
3535 this . setAddResourcesVisibility = this . setAddResourcesVisibility . bind ( this ) ;
3636 this . handleDrop = this . handleDrop . bind ( this ) ;
37+
38+ this . updateRefWidth = this . updateRefWidth . bind ( this ) ;
39+ }
40+
41+ /** */
42+ componentDidMount ( ) {
43+ window . addEventListener ( 'resize' , this . updateRefWidth ) ;
44+ this . updateRefWidth ( ) ;
3745 }
3846
3947 /** */
@@ -70,14 +78,22 @@ export class WorkspaceAdd extends Component {
7078 }
7179 }
7280
81+ /** Update ref width */
82+ updateRefWidth ( ) {
83+ if ( this . ref . current ) {
84+ const refWidth = this . ref . current . offsetWidth ;
85+ this . setState ( { refWidth } ) ;
86+ }
87+ }
88+
7389 /**
7490 * render
7591 */
7692 render ( ) {
7793 const {
78- catalog, setWorkspaceAddVisibility, t, classes,
94+ catalog, setWorkspaceAddVisibility, t, classes, isWorkspaceControlPanelVisible ,
7995 } = this . props ;
80- const { addResourcesOpen } = this . state ;
96+ const { addResourcesOpen, refWidth } = this . state ;
8197
8298 const manifestList = catalog . map ( ( resource , index ) => (
8399 < ManifestListItem
@@ -91,7 +107,14 @@ export class WorkspaceAdd extends Component {
91107
92108 return (
93109 < IIIFDropTarget onDrop = { this . handleDrop } >
94- < div ref = { this . ref } className = { classNames ( ns ( 'workspace-add' ) , classes . workspaceAdd ) } >
110+ < div
111+ ref = { this . ref }
112+ className = { classNames (
113+ ns ( 'workspace-add' ) ,
114+ classes . workspaceAdd ,
115+ { [ classes . workspaceAddMargin ] : isWorkspaceControlPanelVisible } ,
116+ ) }
117+ >
95118 { catalog . length < 1 ? (
96119 < Grid
97120 alignItems = "center"
@@ -146,6 +169,9 @@ export class WorkspaceAdd extends Component {
146169 hideBackdrop : true ,
147170 style : { position : 'absolute' } ,
148171 } }
172+ PaperProps = { {
173+ style : { width : refWidth } ,
174+ } }
149175 >
150176 < Paper
151177 className = { classes . form }
@@ -172,6 +198,7 @@ export class WorkspaceAdd extends Component {
172198 </ Paper >
173199 </ Drawer >
174200 </ div >
201+
175202 </ IIIFDropTarget >
176203 ) ;
177204 }
@@ -184,6 +211,7 @@ WorkspaceAdd.propTypes = {
184211 provider : PropTypes . string ,
185212 } ) ) ,
186213 classes : PropTypes . objectOf ( PropTypes . string ) ,
214+ isWorkspaceControlPanelVisible : PropTypes . bool . isRequired ,
187215 setWorkspaceAddVisibility : PropTypes . func . isRequired ,
188216 t : PropTypes . func ,
189217} ;
0 commit comments