From 662932ac0d3fbfd197e99b56dcc4cb452c12f914 Mon Sep 17 00:00:00 2001 From: Dominic Go Date: Wed, 2 Oct 2024 20:36:29 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20Fix:=20`ModalSheetView`=20Focus?= =?UTF-8?q?=20Event=20(Again)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ModalEventsManager.swift | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/ios/Temp/ModalEventManager/ModalEventsManager.swift b/ios/Temp/ModalEventManager/ModalEventsManager.swift index 0fe85fb..5b310db 100644 --- a/ios/Temp/ModalEventManager/ModalEventsManager.swift +++ b/ios/Temp/ModalEventManager/ModalEventsManager.swift @@ -136,24 +136,29 @@ public final class ModalEventsManager { let didDismiss = modalVC.view.window == nil || !modalVC.isPresentedAsModal; - - guard didDismiss else { - return; - }; let eventManager = ModalEventsManagerRegistry.shared.getManager(forWindow: targetWindow); let modalEntries = eventManager.modalRegistry.getEntriesGrouped(); - modalEntries.topMostModal!.setModalFocusState(.blurred); - modalEntries.secondTopMostModal?.setModalFocusState(.focused); + modalEntries.topMostModal!.setModalFocusState(didDismiss + ? .blurred + : .focused + ); + + modalEntries.secondTopMostModal?.setModalFocusState(didDismiss + ? .focused + : .blurred + ); modalEntries.otherModals?.forEach { $0.setModalFocusState(.blurred); }; - eventManager.modalRegistry.removeEntry(forViewController: modalVC); + if didDismiss { + eventManager.modalRegistry.removeEntry(forViewController: modalVC); + }; }; };