Skip to content

Commit

Permalink
Select all Find In Page text on cmd+f (#2783)
Browse files Browse the repository at this point in the history
  • Loading branch information
mallexxx authored May 17, 2024
1 parent e889707 commit 75e5ccc
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
4 changes: 4 additions & 0 deletions DuckDuckGo/Common/Extensions/NSTextFieldExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ import Common

extension NSTextField {

var isFirstResponder: Bool {
window?.firstResponder == currentEditor()
}

static func label(titled title: String) -> NSTextField {
let label = NSTextField(string: title)

Expand Down
7 changes: 6 additions & 1 deletion DuckDuckGo/FindInPage/FindInPageViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,12 @@ final class FindInPageViewController: NSViewController {
}

func makeMeFirstResponder() {
textField.makeMeFirstResponder()
if textField.isFirstResponder {
// select all on Cmd+F while editing
textField.currentEditor()?.selectAll(nil)
} else {
textField.makeMeFirstResponder()
}
}

private func subscribeToModelChanges() {
Expand Down
4 changes: 0 additions & 4 deletions DuckDuckGo/NavigationBar/View/AddressBarTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ final class AddressBarTextField: NSTextField {
tabCollectionViewModel.isBurner
}

var isFirstResponder: Bool {
window?.firstResponder == currentEditor()
}

private var suggestionResultCancellable: AnyCancellable?
private var selectedSuggestionViewModelCancellable: AnyCancellable?
private var selectedTabViewModelCancellable: AnyCancellable?
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/Tab/TabExtensions/FindInPageTabExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ extension FindInPageTabExtension: NavigationResponder {
}

func navigation(_ navigation: Navigation, didSameDocumentNavigationOf navigationType: WKSameDocumentNavigationType) {
if case .sessionStateReplace = navigationType {
if [.sessionStatePush, .sessionStatePop].contains(navigationType) {
close()
}
}
Expand Down

0 comments on commit 75e5ccc

Please sign in to comment.