diff --git a/DuckDuckGo/Bookmarks/View/AddBookmarkFolderModalView.swift b/DuckDuckGo/Bookmarks/View/AddBookmarkFolderModalView.swift index c225aa0726..31cc06dc04 100644 --- a/DuckDuckGo/Bookmarks/View/AddBookmarkFolderModalView.swift +++ b/DuckDuckGo/Bookmarks/View/AddBookmarkFolderModalView.swift @@ -29,7 +29,7 @@ struct AddBookmarkFolderModalView: ModalView { .fontWeight(.semibold) HStack(spacing: 16) { - Text("Name:", comment: "New bookmark folder dialog folder name field heading") + Text(UserText.newBookmarkDialogBookmarkNameTitle) .frame(height: 22) TextField("", text: $model.folderName) diff --git a/DuckDuckGo/Bookmarks/View/AddBookmarkFolderPopoverView.swift b/DuckDuckGo/Bookmarks/View/AddBookmarkFolderPopoverView.swift index 3b98bdab51..fbb892ba9b 100644 --- a/DuckDuckGo/Bookmarks/View/AddBookmarkFolderPopoverView.swift +++ b/DuckDuckGo/Bookmarks/View/AddBookmarkFolderPopoverView.swift @@ -36,7 +36,7 @@ struct AddBookmarkFolderPopoverView: ModalView { } VStack(alignment: .leading, spacing: 7) { - Text("Name:", comment: "Add Folder popover: folder name text field title") + Text(UserText.newFolderDialogFolderNameTitle) TextField("", text: $model.folderName) .focusedOnAppear() diff --git a/DuckDuckGo/Bookmarks/View/AddBookmarkPopover.swift b/DuckDuckGo/Bookmarks/View/AddBookmarkPopover.swift index bb6102be92..288fa34e46 100644 --- a/DuckDuckGo/Bookmarks/View/AddBookmarkPopover.swift +++ b/DuckDuckGo/Bookmarks/View/AddBookmarkPopover.swift @@ -36,7 +36,7 @@ final class AddBookmarkPopover: NSPopover { let window = addressBar.window else { return .infinite } var frame = window.convertToScreen(addressBar.convert(addressBar.bounds, to: nil)) - frame = frame.insetBy(dx: -36, dy: -window.frame.size.height) + frame = frame.insetBy(dx: -42, dy: -window.frame.size.height) return frame } @@ -53,11 +53,11 @@ final class AddBookmarkPopover: NSPopover { } private func setupBookmarkAddController() { - guard let bookmark else { - contentViewController = NSViewController() - return - } - contentViewController = NSHostingController(rootView: AddBookmarkPopoverView(model: AddBookmarkPopoverViewModel(bookmark: bookmark))) + guard let bookmark else { return } + contentViewController = NSHostingController(rootView: AddBookmarkPopoverView(model: AddBookmarkPopoverViewModel(bookmark: bookmark)) + .legacyOnDismiss { [weak self] in + self?.performClose(nil) + }) } override func show(relativeTo positioningRect: NSRect, of positioningView: NSView, preferredEdge: NSRectEdge) { @@ -65,6 +65,10 @@ final class AddBookmarkPopover: NSPopover { super.show(relativeTo: positioningRect, of: positioningView, preferredEdge: preferredEdge) } + override func performClose(_ sender: Any?) { + self.close() + } + func popoverWillClose() { bookmark = nil } diff --git a/DuckDuckGo/Common/Localizables/UserText.swift b/DuckDuckGo/Common/Localizables/UserText.swift index 4ad1d7cc30..bd0060b054 100644 --- a/DuckDuckGo/Common/Localizables/UserText.swift +++ b/DuckDuckGo/Common/Localizables/UserText.swift @@ -458,6 +458,8 @@ struct UserText { static let newFolder = NSLocalizedString("folder.optionsMenu.newFolder", value: "New Folder", comment: "Option for creating a new folder") static let renameFolder = NSLocalizedString("folder.optionsMenu.renameFolder", value: "Rename Folder", comment: "Option for renaming a folder") static let deleteFolder = NSLocalizedString("folder.optionsMenu.deleteFolder", value: "Delete Folder", comment: "Option for deleting a folder") + static let newFolderDialogFolderNameTitle = NSLocalizedString("add.folder.name", value: "Name:", comment: "Add Folder popover: folder name text field title") + static let newBookmarkDialogBookmarkNameTitle = NSLocalizedString("add.bookmark.name", value: "Name:", comment: "New bookmark folder dialog folder name field heading") static let updateBookmark = NSLocalizedString("bookmark.update", value: "Update Bookmark", comment: "Option for updating a bookmark") diff --git a/DuckDuckGo/Localizable.xcstrings b/DuckDuckGo/Localizable.xcstrings index 61a9e74ffe..4df211baa0 100644 --- a/DuckDuckGo/Localizable.xcstrings +++ b/DuckDuckGo/Localizable.xcstrings @@ -162,6 +162,18 @@ }, "Add to Favorites" : { + }, + "add.bookmark.name" : { + "comment" : "New bookmark folder dialog folder name field heading", + "extractionState" : "extracted_with_value", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "new", + "value" : "Name:" + } + } + } }, "add.favorite" : { "comment" : "Button for adding a favorite bookmark", @@ -175,6 +187,18 @@ } } }, + "add.folder.name" : { + "comment" : "Add Folder popover: folder name text field title", + "extractionState" : "extracted_with_value", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "new", + "value" : "Name:" + } + } + } + }, "add.link.to.bookmarks" : { "comment" : "Context menu item", "extractionState" : "extracted_with_value", @@ -4329,9 +4353,6 @@ } } }, - "Name:" : { - "comment" : "New bookmark folder dialog folder name field heading\nAdd Folder popover: folder name text field title" - }, "navigate.back" : { "comment" : "Context menu item", "extractionState" : "extracted_with_value", diff --git a/DuckDuckGo/NavigationBar/View/AddressBarButtonsViewController.swift b/DuckDuckGo/NavigationBar/View/AddressBarButtonsViewController.swift index b42f15963a..7c8fbd9755 100644 --- a/DuckDuckGo/NavigationBar/View/AddressBarButtonsViewController.swift +++ b/DuckDuckGo/NavigationBar/View/AddressBarButtonsViewController.swift @@ -978,6 +978,22 @@ extension AddressBarButtonsViewController: PermissionContextMenuDelegate { extension AddressBarButtonsViewController: NSPopoverDelegate { + func popoverShouldClose(_ popover: NSPopover) -> Bool { + switch popover { + case bookmarkPopover: + // fix popover reopening on next bookmarkButtonAction (on macOS 11) + DispatchQueue.main.async { [weak self] in + if let bookmarkPopover = self?.bookmarkPopover, bookmarkPopover.isShown { + bookmarkPopover.close() + } + } + return false + + default: + return true + } + } + func popoverWillClose(_ notification: Notification) { switch notification.object as? NSPopover { case bookmarkPopover: @@ -995,6 +1011,7 @@ extension AddressBarButtonsViewController: NSPopoverDelegate { NotificationCenter.default.post(name: .bookmarkPromptShouldShow, object: nil) } updateBookmarkButtonVisibility() + self.bookmarkPopover = nil case privacyDashboardPopover: privacyEntryPointButton.state = .off