소스 검색

Attach root before dismissing modal

Guy Carmeli 6 년 전
부모
커밋
d3c2add2cf

+ 2
- 12
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/Navigator.java 파일 보기

@@ -183,18 +183,8 @@ public class Navigator extends ParentController {
183 183
     }
184 184
 
185 185
     public void dismissModal(final String componentId, CommandListener listener) {
186
-        modalStack.dismissModal(componentId, new CommandListener() {
187
-            @Override
188
-            public void onSuccess(String childId) {
189
-                if (modalStack.size() == 0) contentLayout.addView(root.getView());
190
-                listener.onSuccess(childId);
191
-            }
192
-
193
-            @Override
194
-            public void onError(String message) {
195
-                listener.onError(message);
196
-            }
197
-        });
186
+        if (modalStack.size() == 1) contentLayout.addView(root.getView());
187
+        modalStack.dismissModal(componentId, listener);
198 188
     }
199 189
 
200 190
     public void dismissAllModals(CommandListener listener) {

+ 16
- 0
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/NavigatorTest.java 파일 보기

@@ -412,6 +412,22 @@ public class NavigatorTest extends BaseTest {
412 412
         verify(parentController, times(2)).onViewAppeared();
413 413
     }
414 414
 
415
+    @Test
416
+    public void dismissModal_rootIsAttachedBeforeModalIsDismissed() {
417
+        disableShowModalAnimation(child1, child2);
418
+        disableDismissModalAnimation(child2);
419
+
420
+        uut.setRoot(parentController, new MockPromise());
421
+        uut.showModal(child1, new CommandListenerAdapter());
422
+        uut.showModal(child2, new CommandListenerAdapter());
423
+
424
+        uut.dismissModal(child2.getId(), new CommandListenerAdapter());
425
+        assertThat(parentController.getView().getParent()).isNull();
426
+
427
+        uut.dismissModal(child1.getId(), new CommandListenerAdapter());
428
+        assertThat(parentController.getView().getParent()).isNotNull();
429
+    }
430
+
415 431
     @Test
416 432
     public void dismissAllModals_onViewAppearedInvokedOnRoot() {
417 433
         disableShowModalAnimation(child1);