diff --git a/Sources/Brave/Frontend/Browser/BrowserViewController/BrowserViewController+Onboarding.swift b/Sources/Brave/Frontend/Browser/BrowserViewController/BrowserViewController+Onboarding.swift index 163b3487dec..a6538ff6346 100644 --- a/Sources/Brave/Frontend/Browser/BrowserViewController/BrowserViewController+Onboarding.swift +++ b/Sources/Brave/Frontend/Browser/BrowserViewController/BrowserViewController+Onboarding.swift @@ -221,11 +221,11 @@ extension BrowserViewController { didDismiss() } - borderView.didClickBorderedArea = { + borderView.didClickBorderedArea = { [weak popover] in maskShape.removeFromSuperlayer() borderView.removeFromSuperview() - popover.dismissPopover() { + popover?.dismissPopover() { didClickBorderedArea() } } diff --git a/Sources/Brave/Frontend/Browser/Playlist/Browser/BrowserViewController+Playlist.swift b/Sources/Brave/Frontend/Browser/Playlist/Browser/BrowserViewController+Playlist.swift index 4e76e80d4b2..04c79a36a7e 100644 --- a/Sources/Brave/Frontend/Browser/Playlist/Browser/BrowserViewController+Playlist.swift +++ b/Sources/Brave/Frontend/Browser/Playlist/Browser/BrowserViewController+Playlist.swift @@ -220,7 +220,7 @@ extension BrowserViewController: PlaylistScriptHandlerDelegate, PlaylistFolderSh DispatchQueue.main.async { let model = OnboardingPlaylistModel() let popover = PopoverController(content: OnboardingPlaylistView(model: model)) - popover.previewForOrigin = .init(view: self.topToolbar.locationView.playlistButton, action: { popover in + popover.previewForOrigin = .init(view: self.topToolbar.locationView.playlistButton, action: { [weak tab] popover in guard let item = tab?.playlistItem else { popover.dismissPopover() return @@ -233,8 +233,8 @@ extension BrowserViewController: PlaylistScriptHandlerDelegate, PlaylistFolderSh }) popover.present(from: self.topToolbar.locationView.playlistButton, on: self) - model.onboardingCompleted = { - popover.dismissPopover() + model.onboardingCompleted = { [weak tab, weak popover] in + popover?.dismissPopover() self.openPlaylist(tab: tab, item: tab?.playlistItem) } }