Skip to content

Commit feaa4fc

Browse files
Resolved the Tab key navigation issue for TextInputLayout
1 parent da41cba commit feaa4fc

File tree

2 files changed

+37
-29
lines changed

2 files changed

+37
-29
lines changed

maui/src/TextInputLayout/SfTextInputLayout.Properties.cs

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2193,24 +2193,33 @@ static void OnEnablePasswordTogglePropertyChanged(BindableObject bindable, objec
21932193
}
21942194
}
21952195

2196-
static void OnIsHintFloatedPropertyChanged(BindableObject bindable, object oldValue, object newValue)
2197-
{
2198-
if (bindable is SfTextInputLayout inputLayout && newValue is bool value)
2199-
{
2200-
if (inputLayout.Content is InputView || inputLayout.Content is Microsoft.Maui.Controls.Picker)
2201-
{
2202-
inputLayout.Content.Opacity = value ? 1 : (DeviceInfo.Platform == DevicePlatform.iOS ? 0.00001 : 0);
2203-
}
2204-
else if (inputLayout != null && inputLayout.Content is SfView numericEntry && numericEntry.Children.Count > 0)
2205-
{
2206-
if (numericEntry.Children[0] is Entry numericInputView)
2207-
{
2208-
numericInputView.Opacity = value ? 1 : (DeviceInfo.Platform == DevicePlatform.iOS ? 0.00001 : 0);
2209-
}
2210-
}
2211-
}
2212-
2213-
}
2196+
static void OnIsHintFloatedPropertyChanged(BindableObject bindable, object oldValue, object newValue)
2197+
{
2198+
if (bindable is SfTextInputLayout inputLayout && newValue is bool value)
2199+
{
2200+
double minOpacity = DeviceInfo.Platform.ToString() switch
2201+
{
2202+
nameof(DevicePlatform.MacCatalyst) => 0.011,
2203+
nameof(DevicePlatform.iOS) => 0.00001,
2204+
nameof(DevicePlatform.Android) => 0.00001,
2205+
_ => 0
2206+
};
2207+
2208+
double targetOpacity = value ? 1 : minOpacity;
2209+
2210+
if (inputLayout.Content is InputView || inputLayout.Content is Microsoft.Maui.Controls.Picker)
2211+
{
2212+
inputLayout.Content.Opacity = targetOpacity;
2213+
}
2214+
else if (inputLayout.Content is SfView numericEntry && numericEntry.Children.Count > 0)
2215+
{
2216+
if (numericEntry.Children[0] is Entry numericInputView)
2217+
{
2218+
numericInputView.Opacity = targetOpacity;
2219+
}
2220+
}
2221+
}
2222+
}
22142223

22152224
static void OnInputViewPaddingPropertyChanged(BindableObject bindable, object oldValue, object newValue)
22162225
{

maui/src/TextInputLayout/SfTextInputLayout.cs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -842,33 +842,32 @@ protected override void OnContentChanged(object oldValue, object newValue)
842842
{
843843
UpdateContentMargin(view);
844844
}
845+
double minOpacity = DeviceInfo.Platform.ToString() switch
846+
{
847+
nameof(DevicePlatform.MacCatalyst) => 0.011,
848+
nameof(DevicePlatform.iOS) => 0.00001,
849+
nameof(DevicePlatform.Android) => 0.00001,
850+
_ => 0
851+
};
845852

846853
//For placeholder overlap issue here handled the opacity value for controls.
847854
if (newValue is InputView entryEditorContent)
848855
{
849-
#if ANDROID || IOS
850-
entryEditorContent.Opacity = IsHintFloated ? 1 : 0.00001;
851-
#else
852-
entryEditorContent.Opacity = IsHintFloated ? 1 : 0;
853-
#endif
856+
entryEditorContent.Opacity = IsHintFloated ? 1 : minOpacity;
854857
_initialContentDescription = SemanticProperties.GetDescription(entryEditorContent);
855858
}
856859
else if (newValue is SfView numericEntryContent && numericEntryContent.Children.Count > 0)
857860
{
858861
if (numericEntryContent.Children[0] is Entry numericInputView)
859862
{
860-
#if ANDROID || IOS
861-
numericInputView.Opacity = IsHintFloated ? 1 : 0.00001;
862-
#else
863-
numericInputView.Opacity = IsHintFloated ? 1 : 0;
864-
#endif
863+
numericInputView.Opacity = IsHintFloated ? 1 : minOpacity;
865864
}
866865
}
867866
else if (newValue is Microsoft.Maui.Controls.Picker picker)
868867
{
869868
if (DeviceInfo.Platform != DevicePlatform.WinUI)
870869
{
871-
picker.Opacity = IsHintFloated ? 1 : (DeviceInfo.Platform == DevicePlatform.iOS ? 0.00001 : 0);
870+
picker.Opacity = IsHintFloated ? 1 : minOpacity;
872871
}
873872
}
874873

0 commit comments

Comments
 (0)