Skip to content

Commit cc842f5

Browse files
authored
[Patch 1.0.2] Maintain viewController to prevent dismissing all modals on close (#69)
* Maintain viewController to prevent dismissing all modals on close * Bump + add changelog entry
1 parent d207670 commit cc842f5

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 1.0.2 - February 21, 2024
4+
5+
- Improve "close" event logic by only dismissing the Checkout sheet.
6+
37
## 1.0.1 - February 20, 2024
48

59
- Adds support for view controllers other than the `rootViewController`. This

modules/@shopify/checkout-sheet-kit/ios/ShopifyCheckoutSheetKit.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,12 @@ import React
2828

2929
@objc(RCTShopifyCheckoutSheetKit)
3030
class RCTShopifyCheckoutSheetKit: RCTEventEmitter, CheckoutDelegate {
31-
private var rootViewController: UIViewController?
31+
private var viewControlller: UIViewController?
3232

3333
private var hasListeners = false
3434

3535
override init() {
3636
super.init()
37-
self.rootViewController = UIApplication.shared.delegate?.window??.rootViewController
3837
}
3938

4039
override var methodQueue: DispatchQueue! {
@@ -90,7 +89,8 @@ class RCTShopifyCheckoutSheetKit: RCTEventEmitter, CheckoutDelegate {
9089
if self.hasListeners {
9190
self.sendEvent(withName: "close", body: nil)
9291
}
93-
self.rootViewController?.dismiss(animated: true)
92+
self.viewControlller?.dismiss(animated: true)
93+
self.viewControlller = nil
9494
}
9595
}
9696

@@ -128,6 +128,7 @@ class RCTShopifyCheckoutSheetKit: RCTEventEmitter, CheckoutDelegate {
128128
DispatchQueue.main.async {
129129
if let url = URL(string: checkoutURL), let viewController = self.getCurrentViewController() {
130130
ShopifyCheckoutSheetKit.present(checkout: url, from: viewController, delegate: self)
131+
self.viewControlller = viewController
131132
}
132133
}
133134
}

modules/@shopify/checkout-sheet-kit/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@shopify/checkout-sheet-kit",
33
"license": "MIT",
4-
"version": "1.0.1",
4+
"version": "1.0.2",
55
"main": "lib/commonjs/index.js",
66
"types": "src/index.ts",
77
"source": "src/index.ts",

0 commit comments

Comments
 (0)