-
Notifications
You must be signed in to change notification settings - Fork 11
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
Fixed address bar cleared/losing focus on Navigation #2157
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mallexxx , I started with testing and found this issue where activating another new tab doesn't hide suggestions
https://github.com/duckduckgo/macos-browser/assets/57389842/c2b1134a-57ba-480a-b176-b0084a09b026
good catch, @tomasstrba! fixed |
@mallexxx, switching between homepage and the regular tab makes this weird visual glitch in the address bar. You'll better see it if you download the video and go frame by frame glitch.mov |
LD_RUNPATH_SEARCH_PATHS = $(inherited) @executable_path/../Frameworks @loader_path/../Frameworks | ||
PROVISIONING_PROFILE_SPECIFIER[config=CI][sdk=macosx*] = | ||
SWIFT_EMIT_LOC_STRINGS = NO | ||
TEST_TARGET_NAME = DuckDuckGo Privacy Browser |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not really related change but this made UI test at least launchable
@@ -240,7 +240,9 @@ final class AppDelegate: NSObject, NSApplicationDelegate, FileDownloadManagerDel | |||
|
|||
startupSync() | |||
|
|||
stateRestorationManager.applicationDidFinishLaunching() | |||
if [.normal, .uiTests].contains(NSApp.runType) { | |||
stateRestorationManager.applicationDidFinishLaunching() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
disable state restoration for integration tests
@@ -61,7 +61,6 @@ final class MainView: NSView { | |||
bookmarksBarHeightConstraint = bookmarksBarContainerView.heightAnchor.constraint(equalToConstant: 34) | |||
|
|||
navigationBarTopConstraint = navigationBarContainerView.topAnchor.constraint(equalTo: topAnchor, constant: 38) | |||
addressBarHeightConstraint = navigationBarContainerView.heightAnchor.constraint(equalToConstant: 42) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved tnis into the Navigation Bar Controller in sake of encapsulation and fluid address bar animation
@@ -314,10 +314,7 @@ fileprivate extension MainMenu { | |||
fileprivate extension NavigationBarViewController { | |||
|
|||
var controlsForUserPrevention: [NSControl?] { | |||
return [goBackButton, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was enabling back/forward/refresh buttons after onboarding; they are disabled by default as there‘s no nav history yet
@@ -319,6 +327,8 @@ final class AddressBarViewController: NSViewController { | |||
activeBackgroundView.layer?.borderColor = NSColor.controlAccentColor.withAlphaComponent(0.8).cgColor | |||
activeOuterBorderView.layer?.backgroundColor = accentColor.withAlphaComponent(0.2).cgColor | |||
activeBackgroundView.layer?.borderColor = accentColor.withAlphaComponent(0.8).cgColor | |||
|
|||
addressBarTextField.placeholderString = tabViewModel?.tab.content == .newtab ? UserText.addressBarPlaceholder : "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prevent placeholder blinking when going forward from newtab to a url
@@ -680,17 +680,16 @@ protocol NewWindowPolicyDecisionMaker { | |||
} | |||
return | |||
} | |||
var title = webView.title?.trimmingWhitespace() | |||
if title?.isEmpty ?? true { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we‘ve got this in TabViewModel
if title != self.title { | ||
self.title = title | ||
} | ||
|
||
if let wkBackForwardListItem = webView.backForwardList.currentItem, | ||
content.urlForWebView == wkBackForwardListItem.url { | ||
content.urlForWebView == wkBackForwardListItem.url, | ||
!webView.isLoading, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prevent updating wrong history item while loading
guard let self, | ||
case .url(let url, credential: let credential, .webViewUpdated) = self.content, | ||
url == navigation.url else { return } | ||
self.content = .url(url, credential: credential, source: .historyEntry) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change content type from .webViewUpdated to .historyEntry so the address bar is deactivated on back/forward/refresh
@@ -1285,6 +1308,7 @@ extension Tab/*: NavigationResponder*/ { // to be moved to Tab+Navigation.swift | |||
func didStart(_ navigation: Navigation) { | |||
webViewDidStartNavigationPublisher.send() | |||
delegate?.tabDidStartNavigation(self) | |||
permissions.tabDidStartNavigation() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix encapsulation
@@ -20,6 +20,19 @@ import AppKit | |||
|
|||
final class BrowserTabView: ColorView { | |||
|
|||
// Returns correct subview for the rendering of snapshots | |||
func findContentSubview(containsHostingView: Bool) -> NSView? { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was raising file too long linter issue, moved to the custom view
getView = { [weak self] in self?.transientTabContentViewController?.view } | ||
case .url, .subscription: | ||
getView = { [weak self] in self?.webView } | ||
case .settings: | ||
getView = { [weak self] in self?.preferencesViewController?.view } | ||
case .bookmarks: | ||
getView = { [weak self] in self?.bookmarksViewController?.view } | ||
case .dataBrokerProtection: | ||
getView = { [weak self] in self?.dataBrokerProtectionHomeViewController?.view } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if view is not yet in hierarchy - add it afterwards
updateAddressBarStrings() | ||
if case .didCommit = event { | ||
updateCanBeBookmarked() | ||
updateFavicon() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
address bar should update instantly for some kind of contents except for web view updated; but the favicon and button shouldn‘t blink
self?.updateTitle() | ||
self?.updateFavicon() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only update on actual error state change to avoid blinking
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Address bar activation/deactivation functionality works great now! 👍 I don't see any animation glitch. There are just few details I observed:
- There is a separator below the navigation bar on the new tab page, which shouldn't be there
-
I am not sure if this PR influenced it, but switching tabs is slower. Try switching between new tab page and random regular tabs.
-
Also, there is a significant lag until the webview is presented when SERP is triggered from the address bar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 👍
Thanks, @tomasstrba, I‘ve fixed the divider issue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 👍 Good job! 👏
Task/Issue URL: https://app.asana.com/0/1177771139624306/1206506638670996/f
Description:
Steps to test this PR:
Internal references:
Pull Request Review Checklist
Software Engineering Expectations
Technical Design Template
Pull Request Documentation