-
Notifications
You must be signed in to change notification settings - Fork 7
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
Blockable JS Alerts inside tabs #904
Conversation
89afea1
to
f6488eb
Compare
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.
The code looks fine, good job! 👍
Please see some comments inline
|
||
// MARK: - Alerts | ||
|
||
enum AlertHandlingState { |
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.
please let‘s keep the Tab.swift code with minimal changes needed, the alert state can be managed using only the userInteractionDialog property
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'm not 100% sure about that... but I'll remove the alert blocking functionality now based on your above comment and we can discuss this more if we decide to include that in a later PR
|
||
// MARK: - Alerts | ||
|
||
private var jsAlertController: JSAlertController? |
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.
it seems we don‘t need this extra property here since it‘s held in the closure
|
||
private func showAlert(with query: JSAlertQuery) -> AnyCancellable { | ||
jsAlertController = JSAlertController.create(query) | ||
addAndLayoutChild(self.jsAlertController!) |
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.
please avoid force unwrapping when not needed, extra let jsAlertController = ..create(); self. jsAlertController = jsAlertController would be fine
f463f60
to
79fd318
Compare
import XCTest | ||
@testable import DuckDuckGo_Privacy_Browser | ||
|
||
final class JSAlertViewModelTests: XCTestCase { |
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 🎉
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.
The code looks good, I think Alex caught all the issues before.
There are some swiftlint rules not being respected that would be good to take a look before merging.
That said I found 2 issues
- 1/ This is minor, I'd check with design to see if they think it's a blocker, IMO it is a non critical edge case but if the window is really small and then an alert is displayed, it automatically increases the window size. I'll leave it to you to decide if you want to handle this or not.
See the video:
ResizeBug.mov
- 2/ The color gets messed up if you change the system from/to light/dark mode. IMO a blocker and the reason I'm setting as request changes.
f7d11c6
to
5d41214
Compare
I noticed another issue, the button colour doesn‘t match the system accent colour (is always blue) |
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 think that‘s really close, good job!
I‘ve found several issues and we‘re good to go:
- Alert background isn‘t blocking click events, e.g. Inspector UI elements aren‘t blocked when the alert is displayed, right-clicking background alert displays page context after the alert is hidden
- Scrolling position (for long text) is not zero at appearance (see screenshot attached)
Enter key still doesn‘t work properly
- textField receives gets First Responder even if it‘s hidden
- after selecting the AddressBar and hitting Esc key Enter won‘t dismiss the alert
- Esc key doesn‘t dismiss an
alert()
- it does in Safari - I suggest implementing
acceptsFirstResponder { true }
and handling keys inkeyDown
handler in the JSAlertController, setting first responder tojsAlertController.view
onviewDidAppear
. - As a fallback for the AddressBar deactivated with Esc key I suggest the following:
view.window?.observe(\.firstResponder) { window, _ in
if window.firstResponder is WebView {
self.view.makeMeFirstResponder()
}
}
DuckDuckGo/Autoconsent/UI/CookieConsentUserPermissionView.swift
Outdated
Show resolved
Hide resolved
Another minor thing I noticed is when an empty |
ccb67c7
to
c8d9e8a
Compare
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.
Scrolling problem still present, it‘s fixed for me if I replace sizeToFit() with view.layoutSubtreeIfNeeded()
.. just wondering can it fix the delayed animation problem either?
Other than that, LGTM!
Approved after fixing the issue
# By Dominik Kapusta (4) and others # Via GitHub * develop: Blockable JS Alerts inside tabs (#904) Fix add bookmark / folder modal in fullscreen (#930) Add Mac App Store target (#927) Pull request review checklist added to the pull request template (#935) Version Bump to 0.31.7 Update embedded files Update BSK with autofill 6.1.2 (#942) Migrate to targeted Swift Concurrency checking (#937) Add bundler configuration to limit Gemfile.lock noise (#939) update openssl depedency (#918) Remove tab content when showing TabContent.none (such as for new tabs opened from navigation links) (#938) Update GRDB to 2.0.0 (upstream 6.6.0, SQLCipher 4.5.3) (#933) Sparkle 2 (#934) Bump Submodules/privacy-reference-tests from `de75d51` to `4fdbbb6` (#932) # Conflicts: # DuckDuckGo.xcodeproj/project.pbxproj
Task/Issue URL: https://app.asana.com/0/72649045549333/1201615584595450/f
Tech Design URL: https://app.asana.com/0/481882893211075/1203352316751829/f
CC:
Description:
We need to update our JS alerts so that they:
Steps to test this PR:
https://privacy-test-pages.glitch.me/features/js-alerts.html
Testing checklist:
Internal references:
Software Engineering Expectations
Technical Design Template
When ready for review, remember to post the PR in MM