Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Mac Catalyst] Color inputs and selects fail to display popovers when…
… clicked

https://bugs.webkit.org/show_bug.cgi?id=213157
<rdar://problem/64004135>

Reviewed by Tim Horton.

In Mac Catalyst, presenting popovers using `UIPopoverController` causes the first responder to change. This
means that the WKContentView will resign first responder, which in turn causes the currently presented popover
to be dismissed. This means that popovers for color inputs and select elements will be dismissed immediately
after presentation.

To mitigate this, adapt the approach taken in r259840 to `WKColorPopover` and `WKSelectPopover` by teaching the
base class (`WKRotatingPopover`) to temporarily preserve the focused element in light of first responder changes
while presenting a popover on Mac Catalyst.

* UIProcess/ios/forms/WKFormPopover.mm:
(-[WKRotatingPopover presentPopoverAnimated:]):
(-[WKRotatingPopover dismissPopoverAnimated:]):


Canonical link: https://commits.webkit.org/225941@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@263001 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
whsieh committed Jun 13, 2020
1 parent 34fe4d7 commit 4d4842e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Source/WebKit/ChangeLog
@@ -1,3 +1,24 @@
2020-06-13 Wenson Hsieh <wenson_hsieh@apple.com>

[Mac Catalyst] Color inputs and selects fail to display popovers when clicked
https://bugs.webkit.org/show_bug.cgi?id=213157
<rdar://problem/64004135>

Reviewed by Tim Horton.

In Mac Catalyst, presenting popovers using `UIPopoverController` causes the first responder to change. This
means that the WKContentView will resign first responder, which in turn causes the currently presented popover
to be dismissed. This means that popovers for color inputs and select elements will be dismissed immediately
after presentation.

To mitigate this, adapt the approach taken in r259840 to `WKColorPopover` and `WKSelectPopover` by teaching the
base class (`WKRotatingPopover`) to temporarily preserve the focused element in light of first responder changes
while presenting a popover on Mac Catalyst.

* UIProcess/ios/forms/WKFormPopover.mm:
(-[WKRotatingPopover presentPopoverAnimated:]):
(-[WKRotatingPopover dismissPopoverAnimated:]):

2020-06-13 Sam Weinig <weinig@apple.com>

Extended Color: Experiment with strongly typed ColorComponents
Expand Down
15 changes: 15 additions & 0 deletions Source/WebKit/UIProcess/ios/forms/WKFormPopover.mm
Expand Up @@ -75,6 +75,7 @@ @implementation WKRotatingPopover {
WKContentView *_view;

BOOL _isRotating;
BOOL _isPreservingFocus;
CGPoint _presentationPoint;
RetainPtr<UIPopoverController> _popoverController;
id <WKRotatingPopoverDelegate> _dismissionDelegate;
Expand Down Expand Up @@ -132,6 +133,13 @@ - (UIPopoverArrowDirection)popoverArrowDirections

- (void)presentPopoverAnimated:(BOOL)animated
{
#if PLATFORM(MACCATALYST)
if (!_isPreservingFocus) {
_isPreservingFocus = YES;
[_view preserveFocus];
}
#endif

UIPopoverArrowDirection directions = [self popoverArrowDirections];

BOOL presentWithPoint = !CGPointEqualToPoint(self.presentationPoint, CGPointZero);
Expand All @@ -152,6 +160,13 @@ - (void)presentPopoverAnimated:(BOOL)animated

- (void)dismissPopoverAnimated:(BOOL)animated
{
#if PLATFORM(MACCATALYST)
if (_isPreservingFocus) {
_isPreservingFocus = NO;
[_view releaseFocus];
}
#endif

[_popoverController dismissPopoverAnimated:animated];
}

Expand Down

0 comments on commit 4d4842e

Please sign in to comment.