Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/Core/src/Platform/iOS/ViewExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 AI-Generated Review (multi-model)

[major] Handler Mapper and Property Patterns — This makes wrapper UserInteractionEnabled depend on IsEnabled, but ViewHandler.MapIsEnabled only remaps PlatformView, while MapInputTransparent remaps both the iOS WrapperView container and PlatformView. Concrete failing sequence: a wrapped view with InputTransparent=false is disabled, MapInputTransparent sets the wrapper non-interactive (IsEnabled && !InputTransparent); when the view is later re-enabled, MapIsEnabled updates only the platform view, leaving the wrapper stale and hit-testing still blocked. Please synchronize the iOS/MacCatalyst container whenever IsEnabled changes (and when a container is created), e.g. by centralizing wrapper interaction mapping and calling it from MapIsEnabled, MapInputTransparent, and MapContainerView.

}
}

Expand Down Expand Up @@ -626,7 +626,9 @@ public static void UpdateInputTransparent(this UIView platformView, IViewHandler
return;
}

platformView.UserInteractionEnabled = !view.InputTransparent;
platformView.UserInteractionEnabled = platformView is UIControl

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 AI-Generated Review (multi-model)

[major] Logic and Correctness / iOS-MacCatalyst Platform Specifics — This new ternary correctly folds IsEnabled into the container's hit-test state, but the ITextInput-non-IEditor early-return a few lines above (used for Entry/SearchBar) still computes UserInteractionEnabled purely from IsReadOnly/InputTransparent and ignores IsEnabled entirely. Since MapIsEnabled/MapContainerView now route through MapInputTransparentToContainer -> wrapper.UpdateInputTransparent(handler, view) for every view type, a clipped/shadowed Entry with IsEnabled=false, InputTransparent=false, IsReadOnly=false will have its WrapperView left UserInteractionEnabled=true, inconsistent with the intent of this fix (the container computation should also be view.IsEnabled && !view.InputTransparent for these types, not just for the generic branch).

? !view.InputTransparent
: view.IsEnabled && !view.InputTransparent;
}

public static void UpdateInputTransparent(this UIView platformView, bool isReadOnly, bool inputTransparent)
Expand Down
91 changes: 91 additions & 0 deletions src/Core/tests/UnitTests/ViewExtensionsIOSTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
using Xunit;

#if IOS

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 AI-Generated Review (multi-model)

[major] Regression Prevention and Test Coverage — These tests are compiled only when the IOS symbol is defined, but Core.UnitTests is built as the shared net10.0 unit-test assembly in the saved gate logs, so the filter matched zero tests and this file provides no effective regression coverage. Move this coverage to the iOS Core device-test infrastructure or otherwise ensure the test project targets an iOS TFM so the regression actually runs.

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
}
Loading