Repository navigation
[iOS] Respect InputTransparent when updating UserInteractionEnabled #36305
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,7 +25,7 @@ public static void UpdateIsEnabled(this UIView platformView, IView view) | |
| else | ||
| { | ||
| // Non-UIControl views (like UICollectionView) only get interaction disable | ||
| platformView.UserInteractionEnabled = view.IsEnabled; | ||
| platformView.UserInteractionEnabled = view.IsEnabled && !view.InputTransparent; | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -626,7 +626,9 @@ public static void UpdateInputTransparent(this UIView platformView, IViewHandler | |
| return; | ||
| } | ||
|
|
||
| platformView.UserInteractionEnabled = !view.InputTransparent; | ||
| platformView.UserInteractionEnabled = platformView is UIControl | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
[major] Logic and Correctness / iOS-MacCatalyst Platform Specifics — This new ternary correctly folds |
||
| ? !view.InputTransparent | ||
| : view.IsEnabled && !view.InputTransparent; | ||
| } | ||
|
|
||
| public static void UpdateInputTransparent(this UIView platformView, bool isReadOnly, bool inputTransparent) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| using Xunit; | ||
|
|
||
| #if IOS | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
[major] Regression Prevention and Test Coverage — These tests are compiled only when the |
||
| using Microsoft.Maui.Handlers; | ||
| using Microsoft.Maui.Platform; | ||
| using UIKit; | ||
| #endif | ||
|
|
||
|
|
||
| namespace Microsoft.Maui.UnitTests | ||
| { | ||
| #if IOS | ||
| public class ViewExtensionsIOSTests | ||
| { | ||
| [Theory] | ||
| [InlineData(false, false, false)] | ||
| [InlineData(false, true, false)] | ||
| [InlineData(true, false, true)] | ||
| [InlineData(true, true, false)] | ||
| public void UpdateIsEnabledSetsUserInteractionForNonUIControls(bool isEnabled, bool inputTransparent, bool expectedUserInteractionEnabled) | ||
| { | ||
| var platformView = new UIView(); | ||
| var view = new ViewStub | ||
| { | ||
| IsEnabled = isEnabled, | ||
| InputTransparent = inputTransparent | ||
| }; | ||
|
|
||
| platformView.UpdateIsEnabled(view); | ||
|
|
||
| Assert.Equal(expectedUserInteractionEnabled, platformView.UserInteractionEnabled); | ||
| } | ||
|
|
||
| [Theory] | ||
| [InlineData(false, false, false)] | ||
| [InlineData(false, true, false)] | ||
| [InlineData(true, false, true)] | ||
| [InlineData(true, true, false)] | ||
| public void UpdateIsEnabledSetsUserInteractionOverrideForLayouts(bool isEnabled, bool inputTransparent, bool expectedUserInteractionEnabled) | ||
| { | ||
| var platformView = new LayoutView(); | ||
| var view = new ViewStub | ||
| { | ||
| IsEnabled = isEnabled, | ||
| InputTransparent = inputTransparent | ||
| }; | ||
|
|
||
| platformView.UpdateIsEnabled(view); | ||
|
|
||
| Assert.Equal(expectedUserInteractionEnabled, platformView.UserInteractionEnabledOverride); | ||
| } | ||
|
|
||
| [Theory] | ||
| [InlineData(false, false, false)] | ||
| [InlineData(false, true, false)] | ||
| [InlineData(true, false, true)] | ||
| [InlineData(true, true, false)] | ||
| public void UpdateInputTransparentSetsUserInteractionForNonUIControls(bool isEnabled, bool inputTransparent, bool expectedUserInteractionEnabled) | ||
| { | ||
| var platformView = new UIView(); | ||
| var view = new ViewStub | ||
| { | ||
| IsEnabled = isEnabled, | ||
| InputTransparent = inputTransparent | ||
| }; | ||
|
|
||
| platformView.UpdateInputTransparent(new ViewHandlerStub(), view); | ||
|
|
||
| Assert.Equal(expectedUserInteractionEnabled, platformView.UserInteractionEnabled); | ||
| } | ||
|
|
||
| [Theory] | ||
| [InlineData(false, false, false)] | ||
| [InlineData(false, true, false)] | ||
| [InlineData(true, false, true)] | ||
| [InlineData(true, true, false)] | ||
| public void UpdateInputTransparentSetsUserInteractionOverrideForLayouts(bool isEnabled, bool inputTransparent, bool expectedUserInteractionEnabled) | ||
| { | ||
| var platformView = new LayoutView(); | ||
| var view = new ViewStub | ||
| { | ||
| IsEnabled = isEnabled, | ||
| InputTransparent = inputTransparent | ||
| }; | ||
|
|
||
| platformView.UpdateInputTransparent(new ViewHandlerStub(), view); | ||
|
|
||
| Assert.Equal(expectedUserInteractionEnabled, platformView.UserInteractionEnabledOverride); | ||
| } | ||
| } | ||
| #endif | ||
| } | ||
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.
[major] Handler Mapper and Property Patterns — This makes wrapper
UserInteractionEnableddepend onIsEnabled, butViewHandler.MapIsEnabledonly remapsPlatformView, whileMapInputTransparentremaps both the iOSWrapperViewcontainer andPlatformView. Concrete failing sequence: a wrapped view withInputTransparent=falseis disabled,MapInputTransparentsets the wrapper non-interactive (IsEnabled && !InputTransparent); when the view is later re-enabled,MapIsEnabledupdates only the platform view, leaving the wrapper stale and hit-testing still blocked. Please synchronize the iOS/MacCatalyst container wheneverIsEnabledchanges (and when a container is created), e.g. by centralizing wrapper interaction mapping and calling it fromMapIsEnabled,MapInputTransparent, andMapContainerView.