-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[webview_flutter] always make sure the contentInset or the sum of contentInset and adjustedContentInset is 0 on iOS. #2466
Conversation
FLTWKWebView *webView = [[FLTWKWebView alloc] initWithFrame:CGRectMake(0, 0, 300, 400)]; | ||
webView.scrollView.contentInset = UIEdgeInsetsMake(0, 0, 300, 0); | ||
XCTAssertFalse(UIEdgeInsetsEqualToEdgeInsets(webView.scrollView.contentInset, UIEdgeInsetsZero)); | ||
webView.frame = CGRectMake(0, 0, 300, 200); |
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.
Lets also assert that the frame was updated, as we are overriding the setter.
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.
done
webView.frame = CGRectMake(0, 0, 300, 200); | ||
XCTAssertTrue(UIEdgeInsetsEqualToEdgeInsets(webView.scrollView.contentInset, UIEdgeInsetsZero)); | ||
|
||
if (@available(iOS 11, *)) { |
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.
What's the effect of such a condition on a XCTest, are we running once with iOS < 11 and once with iOS >= 11?
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.
our ci is currently running on the latest iOS (13), I added this condition in case we decided to run CI for a lower iOS version. In a lower version, since there is no adjustedContentInset, we don't need to test it.
@@ -21,4 +21,7 @@ NS_ASSUME_NONNULL_BEGIN | |||
- (instancetype)initWithMessenger:(NSObject<FlutterBinaryMessenger>*)messenger; | |||
@end | |||
|
|||
@interface FLTWKWebView : WKWebView |
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.
nit: add class docs
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.
done
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
…tentInset and adjustedContentInset is 0 on iOS. (flutter#2466)
Description
IOS sometimes updates the contentInset of the scroll view (for example to incorporate the keyboard) when the frame of the WebView changes.
The contentInset of the scrollview should be reverted to 0 after changing the view's frame so it doesn't interfere with Flutter.
This PR also fixes the XCTest test cases to follow XCTest's naming conventions.
Related Issues
Fixes flutter/flutter#45482
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]
). This will ensure a smooth and quick review process.///
).flutter analyze
) does not report any problems on my PR.Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?