Skip to content

Commit

Permalink
Fix pinned button requiring double click
Browse files Browse the repository at this point in the history
  • Loading branch information
aataraxiaa committed Mar 8, 2024
1 parent d88e0bf commit 1632d80
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DuckDuckGo/NavigationBar/View/NavigationBarPopovers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ final class NavigationBarPopovers: PopoverPresenter {
}

func passwordManagementButtonPressed(usingView view: NSView, withDelegate delegate: NSPopoverDelegate) {
if passwordPopoverPresenter.popoverIsDisplayed == true {
if passwordPopoverPresenter.popoverIsDisplayed == true && passwordPopoverPresenter.popoverIsInCurrentWindow {
passwordPopoverPresenter.dismiss()
} else {
showPasswordManagementPopover(selectedCategory: nil, usingView: view, withDelegate: delegate)
Expand Down
5 changes: 5 additions & 0 deletions DuckDuckGo/SecureVault/View/PasswordPopoverPresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ protocol PasswordPopoverPresenter {
var passwordDomain: String? { get set }
var popoverIsDirty: Bool { get }
var popoverIsDisplayed: Bool { get }
var popoverIsInCurrentWindow: Bool { get }
func show(under view: NSView, withDomain domain: String?, selectedCategory category: SecureVaultSorting.Category?)
func show(under view: NSView, withSelectedAccount: SecureVaultModels.WebsiteAccount)
func dismiss()
Expand All @@ -49,6 +50,10 @@ final class DefaultPasswordPopoverPresenter: PasswordPopoverPresenter, PopoverPr
popover?.isShown ?? false
}

var popoverIsInCurrentWindow: Bool {
popover?.mainWindow == NSApplication.shared.keyWindow
}

/// Note: Dismisses any previously displayed popover before showing a new one
func show(under view: NSView, withDomain domain: String?, selectedCategory category: SecureVaultSorting.Category?) {
show(under: view, withDomain: domain).select(category: category)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ final class MockPasswordPopoverPresenter: PasswordPopoverPresenter {
isDisplayed
}

var popoverIsInCurrentWindow: Bool {
false
}

func show(under view: NSView, withDomain domain: String?, selectedCategory category: DuckDuckGo_Privacy_Browser.SecureVaultSorting.Category?) {
didShowWithCategory = true
}
Expand Down

0 comments on commit 1632d80

Please sign in to comment.