@@ -26,8 +26,7 @@ import {
2626 MDCDismissibleDrawerFoundation ,
2727 MDCModalDrawerFoundation ,
2828 util ,
29- // @ts -ignore no .d.ts file
30- } from '@material/drawer/dist/mdc.drawer' ;
29+ } from '@material/drawer' ;
3130// @ts -ignore no .d.ts file
3231import { MDCListFoundation } from '@material/list/dist/mdc.list' ;
3332import DrawerHeader from './Header' ;
@@ -62,7 +61,7 @@ const isRefObject = function(ref: DrawerProps['innerRef']): ref is React.RefObje
6261
6362class Drawer extends React . Component < DrawerProps , DrawerState > {
6463 previousFocus : HTMLElement | null = null ;
65- foundation : MDCDismissibleDrawerFoundation | MDCModalDrawerFoundation ;
64+ foundation ? : MDCDismissibleDrawerFoundation | MDCModalDrawerFoundation ;
6665 focusTrap ?: FocusTrap ;
6766 drawerElement : React . RefObject < HTMLDivElement > = React . createRef ( ) ;
6867
@@ -113,7 +112,7 @@ class Drawer extends React.Component<DrawerProps, DrawerState> {
113112 if ( changedToModal || changedToDismissible ) {
114113 this . initFoundation ( ) ;
115114 }
116- if ( open !== prevProps . open ) {
115+ if ( open !== prevProps . open && this . foundation ) {
117116 open ? this . foundation . open ( ) : this . foundation . close ( ) ;
118117 }
119118 }
@@ -124,7 +123,7 @@ class Drawer extends React.Component<DrawerProps, DrawerState> {
124123 }
125124
126125 private initializeFocusTrap = ( ) => {
127- this . focusTrap = util . createFocusTrapInstance ( this . drawerElement . current ) ;
126+ this . focusTrap = util . createFocusTrapInstance ( this . drawerElement . current ! ) ;
128127 } ;
129128
130129 get classes ( ) {
@@ -191,13 +190,13 @@ class Drawer extends React.Component<DrawerProps, DrawerState> {
191190 handleKeyDown = ( evt : React . KeyboardEvent < HTMLElement > ) => {
192191 this . props . onKeyDown ! ( evt ) ;
193192 if ( ! this . foundation ) return ;
194- this . foundation . handleKeydown ( evt ) ;
193+ this . foundation . handleKeydown ( evt . nativeEvent ) ;
195194 } ;
196195
197196 handleTransitionEnd = ( evt : React . TransitionEvent < HTMLElement > ) => {
198197 this . props . onTransitionEnd ! ( evt ) ;
199198 if ( ! this . foundation ) return ;
200- this . foundation . handleTransitionEnd ( evt ) ;
199+ this . foundation . handleTransitionEnd ( evt . nativeEvent ) ;
201200 } ;
202201
203202 attachRef = ( node : HTMLElement ) => {
@@ -230,9 +229,9 @@ class Drawer extends React.Component<DrawerProps, DrawerState> {
230229 children,
231230 className,
232231 innerRef,
232+ modal,
233233 /* eslint-enable no-unused-vars */
234234 tag : Tag ,
235- modal,
236235 ...otherProps
237236 } = this . props ;
238237
@@ -253,11 +252,12 @@ class Drawer extends React.Component<DrawerProps, DrawerState> {
253252 </ React . Fragment >
254253 ) ;
255254 }
255+
256256 renderScrim ( ) {
257257 return (
258258 < div
259259 className = 'mdc-drawer-scrim'
260- onClick = { ( ) => this . foundation . handleScrimClick ( ) }
260+ onClick = { ( ) => ( this . foundation as MDCModalDrawerFoundation ) . handleScrimClick ( ) }
261261 />
262262 ) ;
263263 }
0 commit comments