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

fix address bar weirdness #2810

Merged
merged 3 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion DuckDuckGo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

autoClear = AutoClear(worker: main)
Task {
await autoClear?.clearDataIfEnabled()
await autoClear?.clearDataIfEnabled(launching: true)
}

AppDependencyProvider.shared.voiceSearchHelper.migrateSettingsFlagIfNecessary()
Expand Down
6 changes: 4 additions & 2 deletions DuckDuckGo/AutoClear.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class AutoClear {
}

@MainActor
func clearDataIfEnabled() async {
func clearDataIfEnabled(launching: Bool = false) async {
guard let settings = AutoClearSettingsModel(settings: appSettings) else { return }

if settings.action.contains(.clearTabs) {
Expand All @@ -56,7 +56,9 @@ class AutoClear {
await worker.forgetData()
}

worker.clearDataFinished(self)
if !launching {
worker.clearDataFinished(self)
}
}

/// Note: function is parametrised because of tests.
Expand Down
15 changes: 5 additions & 10 deletions DuckDuckGo/OmniBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -174,17 +174,9 @@ class OmniBar: UIView {
guard let range = field.selectedTextRange else { return }
UIPasteboard.general.string = field.text(in: range)
}

textField.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector( onTextFieldTapped )))
}

var textFieldTapped = false

@objc
private func onTextFieldTapped() {
textFieldTapped = true
textField.becomeFirstResponder()
}
var textFieldTapped = true

private func configureSeparator() {
separatorHeightConstraint.constant = 1.0 / UIScreen.main.scale
Expand Down Expand Up @@ -374,6 +366,10 @@ class OmniBar: UIView {
}

@discardableResult override func becomeFirstResponder() -> Bool {
textFieldTapped = false
defer {
textFieldTapped = true
}
return textField.becomeFirstResponder()
}

Expand Down Expand Up @@ -501,7 +497,6 @@ extension OmniBar: UITextFieldDelegate {

func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {
omniDelegate?.onTextFieldWillBeginEditing(self, tapped: textFieldTapped)
textFieldTapped = false
return true
}

Expand Down
Loading