@@ -50,8 +50,14 @@ class MDCBottomSheetControllerDelegateImpl extends NSObject {
50
50
}
51
51
bottomSheetControllerDidDismissBottomSheet ( controller : MDCBottomSheetController ) {
52
52
// called when clicked on background
53
- const owner = this . _owner . get ( ) ;
54
- owner && owner . _unloadBottomSheet ( ) ;
53
+ // this is called too soon to "dispose" the view. But we dont have a way
54
+ // to know when the animation is finished.
55
+ //Consequently with background tap we see the view disappear
56
+ // so we timeout a bit
57
+ setTimeout ( ( ) => {
58
+ const owner = this . _owner . get ( ) ;
59
+ owner && owner . _unloadBottomSheet ( ) ;
60
+ } , 200 ) ;
55
61
}
56
62
bottomSheetControllerStateChangedState ( controller : MDCBottomSheetController , state : MDCSheetState ) {
57
63
// called when swiped
@@ -434,13 +440,25 @@ export class ViewWithBottomSheet extends ViewWithBottomSheetBase {
434
440
}
435
441
436
442
_bottomSheetClosed ( ) {
443
+ console . log ( '_bottomSheetClosed' ) ;
444
+ super . _bottomSheetClosed ( ) ;
445
+
437
446
if ( this . bottomSheetController ) {
438
447
this . bottomSheetController . delegate = null ;
439
448
this . bottomSheetController = null ;
440
449
}
441
450
this . bottomSheetControllerDelegate = null ;
451
+ // it is very important to clear the viewController as N does not do it
452
+ // and the destroy of the view from svelte could trigger a layout pass on the viewController
453
+ this . viewController = null ;
442
454
}
443
455
protected _hideNativeBottomSheet ( parent : View , whenClosedCallback : ( ) => void ) {
456
+ if ( ! this . viewController ) {
457
+ // when clicking on background we dont need to dismiss, already done
458
+ whenClosedCallback ?.( ) ;
459
+ return ;
460
+ }
461
+ console . log ( '_hideNativeBottomSheet' , new Error ( ) . stack ) ;
444
462
const parentWithController = IOSHelper . getParentWithViewController ( parent ) ;
445
463
if ( ! parent || ! parentWithController ) {
446
464
Trace . error ( 'Trying to hide bottom-sheet view but no parent with viewController specified.' ) ;
@@ -453,17 +471,11 @@ export class ViewWithBottomSheet extends ViewWithBottomSheetBase {
453
471
}
454
472
455
473
_unloadBottomSheet ( ) {
474
+ console . log ( '_unloadBottomSheet' ) ;
456
475
if ( this . isLoaded ) {
457
476
this . callUnloaded ( ) ;
458
477
}
459
- this . _isAddedToNativeVisualTree = false ;
460
- this . _tearDownUI ( true ) ;
461
- this . parent = null ;
462
-
463
478
this . _onDismissBottomSheetCallback && this . _onDismissBottomSheetCallback ( ) ;
464
- // it is very important to clear the viewController as N does not do it
465
- // and the destroy of the view from svelte could trigger a layout pass on the viewController
466
- this . viewController = null ;
467
479
}
468
480
}
469
481
0 commit comments