-
-
Notifications
You must be signed in to change notification settings - Fork 756
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
Scroll cursor onscreen if needed on text entry, arrow key use or rotation. #2842
Conversation
wmf.commands = { | ||
keyboardHeightChanged: (newHeight) => { |
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.
Didn't find a way to determine that the keyboard appeared purely from JS land... thought maybe the viewport dimensions would change or something. In native land adjustedContentInset
changes as the keyboard's size changes, but didn't see anything in JS land that tracks with that change. If we had a way to directly or indirectly determine changes to keyboard height from JS land we wouldn't need this keyboardHeightChanged
message from native land or even the resize
listener I added. There's a chance I may have missed something...
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.
You could monitor changes to adjustedContentInset
with the UIScrollViewDelegate
method scrollViewDidChangeAdjustedContentInset
instead of the keyboard notification and it'd take into account any overlays that aren't the keyboard (for example if the edit toolbar moves into the view itself to keep it visible even after the keyboard is dismissed). You could also pass the full insets to JS to account for any overlays we'd add to the top.
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 like it!
Added WIP tag - found a bug. |
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.
Requesting change to use scrollViewDidChangeAdjustedContentInset
by becoming the the webView.scrollView.delegate
instead of listening to the keyboard frame notification
@@ -46,6 +48,18 @@ class SectionEditorViewController: UIViewController { | |||
apply(theme: theme) | |||
|
|||
WMFAuthenticationManager.sharedInstance.loginWithSavedCredentials { (_) in } | |||
|
|||
NotificationCenter.default.addObserver(forName: UIWindow.keyboardDidChangeFrameNotification, object: nil, queue: nil, using: { [weak self] notification in |
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 observation is never removed, so even though self
is weak, it continues to fire with self as nil even after the VC is deallocated.
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.
Ah thx. We may have same issue in ViewController.swift
. I can fix it there when I fix this.
wmf.commands = { | ||
keyboardHeightChanged: (newHeight) => { |
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.
You could monitor changes to adjustedContentInset
with the UIScrollViewDelegate
method scrollViewDidChangeAdjustedContentInset
instead of the keyboard notification and it'd take into account any overlays that aren't the keyboard (for example if the edit toolbar moves into the view itself to keep it visible even after the keyboard is dismissed). You could also pass the full insets to JS to account for any overlays we'd add to the top.
…arance for determining portion of webview covered by keyboard
https://phabricator.wikimedia.org/T213452
Ensures text insertion point is onscreen when...
NOTE: there is a simulator-only bug: if you scroll down, then tap the up arrow key on your keyboard repeatedly until the cursor moves off the top of the screen, it will jump back down in jarring way. Is sim-only because it doesn't happen if you're on device and using the
^
button instead of the up arrow keyboard key (which doesn't exists on device).