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

First reponder issues when switching tabs #464

Merged
merged 6 commits into from
Mar 17, 2022

Conversation

tomasstrba
Copy link
Contributor

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:

  1. Switch between various content types (loaded website, new page, preferences, bookmark management page,..) and make sure address bar is focused only if new page is selected. (also make sure content is displayed correctly)
  2. Verify the error view (load non-existing domain, turn of connection)

Internal references:

Software Engineering Expectations
Technical Design Template
When ready for review, remember to post the PR in MM

/// 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?) {
Copy link
Contributor Author

@tomasstrba tomasstrba Mar 10, 2022

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?) {
Copy link
Contributor Author

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 🙏

@brindy brindy assigned brindy and tomasstrba and unassigned brindy Mar 10, 2022
@bstandaert-ddg
Copy link

Two issues I'm seeing with this branch:

  1. Error pages show the wrong tab:
Screen.Recording.2022-03-10.at.2.37.41.PM.mov
  1. If I focus the address bar and switch tabs with the keyboard, the address bar stays focused on the new tab:
Screen.Recording.2022-03-10.at.2.37.28.PM.mov

@tomasstrba
Copy link
Contributor Author

@bstandaert-ddg, thanks for your testing! All issues you mentioned should be fixed.

@tomasstrba tomasstrba requested a review from ayoy March 17, 2022 13:32
@tomasstrba tomasstrba assigned ayoy and unassigned tomasstrba Mar 17, 2022
@@ -319,16 +310,17 @@ final class BrowserTabViewController: NSViewController {
showTransientTabContentController(OnboardingViewController.create(withDelegate: self))

case .url:
removeAllTabContent(includingWebView: false)
Copy link
Contributor Author

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

Copy link
Collaborator

@ayoy ayoy left a 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 :)

@ayoy ayoy assigned tomasstrba and unassigned ayoy Mar 17, 2022
@tomasstrba
Copy link
Contributor Author

Thanks for a careful review @ayoy 🙏

@tomasstrba tomasstrba merged commit 6c0cba6 into develop Mar 17, 2022
@tomasstrba tomasstrba deleted the tom/first-responder-fix branch March 17, 2022 22:10
samsymons added a commit that referenced this pull request Mar 25, 2022
# 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants