-
Notifications
You must be signed in to change notification settings - Fork 16
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
First reponder issues when switching tabs #464
Conversation
…ft in order to fix first responder
/// 1. No URL is provided, so the webview should be hidden in favor of showing the default UI elements. | ||
/// 2. A URL is provided for the first time, so the webview should be added as a subview and the URL should be loaded. | ||
/// 3. A URL is provided after already adding the webview, so the webview should be reloaded. | ||
private func updateInterface(tabViewModel: TabViewModel?) { |
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.
I basically merged this method with show(tabContent:) because I believe it was only adding complexity. The general point of these methods was the same: adjust content of VC based on tab content.
@@ -300,9 +292,14 @@ final class BrowserTabViewController: NSViewController { | |||
(view.window?.windowController as? MainWindowController)?.userInteraction(prevented: true) | |||
} | |||
|
|||
private func show(tabContent content: Tab.TabContent?) { | |||
private func showTabContent(of tabViewModel: TabViewModel?) { |
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 is the result of refactoring. One method adjusting this view controller based on tabViewModel and its content. Hope this is more readable then the previous solution and I pray I didn't introduce a bug. Please review carefully 🙏
Two issues I'm seeing with this branch:
Screen.Recording.2022-03-10.at.2.37.41.PM.mov
Screen.Recording.2022-03-10.at.2.37.28.PM.mov |
@bstandaert-ddg, thanks for your testing! All issues you mentioned should be fixed. |
@@ -319,16 +310,17 @@ final class BrowserTabViewController: NSViewController { | |||
showTransientTabContentController(OnboardingViewController.create(withDelegate: self)) | |||
|
|||
case .url: | |||
removeAllTabContent(includingWebView: false) |
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.
Before, we were triggering this method with each URL change. It was a bit unnecessary
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! I did quite extensive testing and all worked fine, and the code looks cleaner now :)
Thanks for a careful review @ayoy 🙏 |
# By Tomas Strba (3) and others # Via GitHub * develop: Testing Checklist Updates (#480) Xcode Clean Up (#479) External App Scheme permission (#419) Update dashboard to correct version (#477) Update BSK to fix percent encoding query parameters (#475) bump version 0.21.0 add alternate for paste and match with style (#474) First reponder issues when switching tabs (#464) Pre-beta copy updates (#472) Improvements to data clearing (#467) Open feedback form upon tapping "Send Feedback" in the About page (#473) new tab tweaks (#471) # Conflicts: # DuckDuckGo.xcodeproj/project.pbxproj # DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved # DuckDuckGo/Secure Vault/View/SaveIdentityPopover.swift # DuckDuckGo/Secure Vault/View/SaveIdentityViewController.swift # DuckDuckGo/Secure Vault/View/SavePaymentMethodPopover.swift # DuckDuckGo/Secure Vault/View/SavePaymentMethodViewController.swift
Task/Issue URL: https://app.asana.com/0/1177771139624306/1201906946231191/f
Tech Design URL:
CC:
Description:
Correction of how content is switched in BrowserTabViewController.swift in order to fix selection of the first responder.
Additionally, there is a small recatoring making code more straightforward, easier to maintain and it prevents from unnecessary code execution happening with each URL change or tab selection.
Steps to test this PR:
Internal references:
Software Engineering Expectations
Technical Design Template
When ready for review, remember to post the PR in MM