Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to tab implementation #3660

Merged
merged 23 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
228c50f
Switch to tab implementation
mallexxx Dec 11, 2024
8dc9c3f
separate tab search for fire windows
mallexxx Dec 16, 2024
1da7874
Add FeatureFlag
mallexxx Dec 18, 2024
d44ab67
Deduplicate open tab suggestions and internal pages
mallexxx Dec 18, 2024
d3764b1
update icon
mallexxx Dec 20, 2024
eeb2866
move switchToTab logics from AddressBarTextField to WindowControllers…
mallexxx Dec 20, 2024
f59ee98
use "naked" url for dedup
mallexxx Dec 20, 2024
3868d4c
Merge remote-tracking branch 'origin/main' into alex/tab-search
mallexxx Dec 20, 2024
8d3cf89
Design Review adjustments; Add Switch to Tab Address Bar box
mallexxx Dec 23, 2024
4c2c838
fix switch to tab colors updating on theme switch
mallexxx Dec 24, 2024
18f13cf
add Switch to Tab box to suggestions cell
mallexxx Dec 24, 2024
04e7a47
deduplicate internal page suggestions
mallexxx Dec 24, 2024
c10701b
add pixel
mallexxx Jan 13, 2025
2fd97ac
reset address bar value when switching to a tab
mallexxx Jan 13, 2025
cf10322
don‘t close window with a pinned tab selected
mallexxx Jan 13, 2025
942533c
disable pinned tabs suggestions in a Fire Window
mallexxx Jan 13, 2025
1222254
disable Pin Tab command in Fire Window
mallexxx Jan 13, 2025
f164233
Merge remote-tracking branch 'origin/main' into alex/tab-search
mallexxx Jan 14, 2025
4470420
fix tests
mallexxx Jan 14, 2025
297c202
ColorView fix appearance not updated on system theme change
mallexxx Jan 15, 2025
2697958
Localization
mallexxx Jan 16, 2025
757a2b7
Place open tab suggestions before history and bookmark suggestions (#…
mallexxx Jan 17, 2025
038e9ba
fix typo
mallexxx Jan 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "Arrow-Right-12.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "Window-Tabbed-16D 1.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}
Binary file not shown.
5 changes: 5 additions & 0 deletions DuckDuckGo/Common/Localizables/UserText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@ struct UserText {
static let searchDuckDuckGoSuffix = NSLocalizedString("address.bar.search.suffix",
value: "Search DuckDuckGo",
comment: "Suffix of searched terms in address bar. Example: best watching machine . Search DuckDuckGo")
static let duckDuckGoSearchSuffix = NSLocalizedString("address.bar.search.open.tab.suffix",
value: "DuckDuckGo Search",
comment: "Suffix of DuckDuckGo Search open tab suggestion. Example: cats – DuckDuckGo Search")
static let addressBarVisitSuffix = NSLocalizedString("address.bar.visit.suffix",
value: "Visit",
comment: "Address bar suffix of possibly visited website. Example: spreadprivacy.com . Visit spreadprivacy.com")
Expand Down Expand Up @@ -1435,4 +1438,6 @@ struct UserText {
static let homePagePromotionFreemiumDBPPostScanEngagementButtonTitle = "View Results"

static let removeSuggestionTooltip = NSLocalizedString("remove.suggestion.tooltip", value: "Remove from browsing history", comment: "Tooltip for the button which removes the history entry from the history")

static let switchToTab = NSLocalizedString("switch.to.tab", value: "Switch to Tab", comment: "Suggestion to switch to an open tab button title")
}
2 changes: 1 addition & 1 deletion DuckDuckGo/HomePage/Model/HomePageAddressBarModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ extension HomePage.Models {
return AddressBarViewController(
coder: coder,
tabCollectionViewModel: tabCollectionViewModel,
isBurner: tabCollectionViewModel.isBurner,
burnerMode: tabCollectionViewModel.burnerMode,
popovers: nil,
isSearchBox: true
)
Expand Down
24 changes: 24 additions & 0 deletions DuckDuckGo/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -1229,6 +1229,18 @@
}
}
},
"address.bar.search.open.tab.suffix" : {
"comment" : "Suffix of DuckDuckGo Search open tab suggestion. Example: cats – DuckDuckGo Search",
"extractionState" : "extracted_with_value",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "DuckDuckGo Search"
}
}
}
},
"address.bar.search.suffix" : {
"comment" : "Suffix of searched terms in address bar. Example: best watching machine . Search DuckDuckGo",
"extractionState" : "extracted_with_value",
Expand Down Expand Up @@ -63955,6 +63967,18 @@
}
}
},
"switch.to.tab" : {
"comment" : "Suggestion to switch to an open tab button title",
"extractionState" : "extracted_with_value",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "Switch to Tab"
}
}
}
},
"sync.promo.bookmarks.message" : {
"comment" : "Message for the Sync Promotion banner when user has bookmarks that can be synced",
"extractionState" : "extracted_with_value",
Expand Down
1 change: 0 additions & 1 deletion DuckDuckGo/MainWindow/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ final class MainViewController: NSViewController {
}()

navigationBarViewController = NavigationBarViewController.create(tabCollectionViewModel: tabCollectionViewModel,
isBurner: isBurner,
networkProtectionPopoverManager: networkProtectionPopoverManager,
networkProtectionStatusReporter: networkProtectionStatusReporter,
autofillPopoverPresenter: autofillPopoverPresenter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -747,10 +747,12 @@ final class AddressBarButtonsViewController: NSViewController {
imageButton.image = .web
case .browsing:
imageButton.image = tabViewModel.favicon
case .editing(isUrl: true):
case .editing(.url):
imageButton.image = .web
case .editing(isUrl: false):
case .editing(.text):
imageButton.image = .search
case .editing(.openTabSuggestion):
imageButton.image = .openTabSuggestion
default:
imageButton.image = nil
}
Expand Down
55 changes: 35 additions & 20 deletions DuckDuckGo/NavigationBar/View/AddressBarTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,13 @@ final class AddressBarTextField: NSTextField {
PixelKit.fire(autocompletePixel)
}

if NSApp.isCommandPressed {
if case .internalPage(title: let title, url: let url) = suggestion,
url == .bookmarks || url.isSettingsURL {
// when choosing an internal page suggestion preffer already open matching tab
switchTo(OpenTab(title: title, url: url))
} else if case .openTab(let title, url: let url) = suggestion {
switchTo(OpenTab(title: title, url: url))
} else if NSApp.isCommandPressed {
openNew(NSApp.isOptionPressed ? .window : .tab, selected: NSApp.isShiftPressed, suggestion: suggestion)
} else {
hideSuggestionWindow()
Expand Down Expand Up @@ -486,6 +492,10 @@ final class AddressBarTextField: NSTextField {
}
}

private func switchTo(_ tab: OpenTab) {
mallexxx marked this conversation as resolved.
Show resolved Hide resolved
WindowControllersManager.shared.show(url: tab.url, source: .switchToOpenTab, newTab: true /* in case not found */)
}

private func makeUrl(suggestion: Suggestion?, stringValueWithoutSuffix: String, completion: @escaping (URL?, String, Bool) -> Void) {
let finalUrl: URL?
let userEnteredValue: String
Expand Down Expand Up @@ -890,8 +900,7 @@ extension AddressBarTextField {

case .bookmark(title: _, url: let url, isFavorite: _, allowedInTopHits: _),
.historyEntry(title: _, url: let url, allowedInTopHits: _),
.internalPage(title: _, url: let url),
.openTab(title: _, url: let url):
.internalPage(title: _, url: let url):
if let title = suggestionViewModel.title,
!title.isEmpty,
suggestionViewModel.autocompletionString != title {
Expand All @@ -901,7 +910,8 @@ extension AddressBarTextField {
} else {
self = .url(url)
}

case .openTab(title: _, url: let url):
self = .openTab(url)
case .unknown:
self = Suffix.search
}
Expand All @@ -911,6 +921,7 @@ extension AddressBarTextField {
case visit(host: String)
case url(URL)
case title(String)
case openTab(URL)

func toAttributedString(size: CGFloat, isBurner: Bool) -> NSAttributedString {
let suffixColor = isBurner ? NSColor.burnerAccent : NSColor.addressBarSuffix
Expand All @@ -922,6 +933,8 @@ extension AddressBarTextField {
}

static let searchSuffix = " – \(UserText.searchDuckDuckGoSuffix)"
static let searchOpenTabSuffix = " – \(UserText.duckDuckGoSearchSuffix)"
static let internalPageOpenTabSuffix = " – \(UserText.duckDuckGo)"
static let visitSuffix = " – \(UserText.addressBarVisitSuffix)"

var string: String {
Expand All @@ -930,14 +943,16 @@ extension AddressBarTextField {
return Self.searchSuffix
case .visit(host: let host):
return "\(Self.visitSuffix) \(host)"
case .url(let url):
if url.isDuckDuckGoSearch {
return Self.searchSuffix
} else {
return " – " + url.toString(decodePunycode: false,
dropScheme: true,
dropTrailingSlash: false)
}
case .openTab(let url) where url.isDuckDuckGoSearch:
return Self.searchOpenTabSuffix
case .openTab(let url) where url.isDuckURLScheme:
return Self.internalPageOpenTabSuffix
case .url(let url) where url.isDuckDuckGoSearch:
return Self.searchSuffix
case .url(let url), .openTab(let url):
return " – " + url.toString(decodePunycode: false,
dropScheme: true,
dropTrailingSlash: false)
case .title(let title):
return " – " + title
}
Expand Down Expand Up @@ -1037,14 +1052,14 @@ extension AddressBarTextField: NSTextFieldDelegate {
return true

case #selector(NSResponder.deleteBackward(_:)),
#selector(NSResponder.deleteForward(_:)),
#selector(NSResponder.deleteToMark(_:)),
#selector(NSResponder.deleteWordForward(_:)),
#selector(NSResponder.deleteWordBackward(_:)),
#selector(NSResponder.deleteToEndOfLine(_:)),
#selector(NSResponder.deleteToEndOfParagraph(_:)),
#selector(NSResponder.deleteToBeginningOfLine(_:)),
#selector(NSResponder.deleteBackwardByDecomposingPreviousCharacter(_:)):
#selector(NSResponder.deleteForward(_:)),
#selector(NSResponder.deleteToMark(_:)),
#selector(NSResponder.deleteWordForward(_:)),
#selector(NSResponder.deleteWordBackward(_:)),
#selector(NSResponder.deleteToEndOfLine(_:)),
#selector(NSResponder.deleteToEndOfParagraph(_:)),
#selector(NSResponder.deleteToBeginningOfLine(_:)),
#selector(NSResponder.deleteBackwardByDecomposingPreviousCharacter(_:)):

suggestionContainerViewModel?.clearSelection()
return false
Expand Down
Loading
Loading