Skip to content

Commit 2651f6d

Browse files
committed
review changes
1 parent cbe3c71 commit 2651f6d

File tree

5 files changed

+46
-6
lines changed

5 files changed

+46
-6
lines changed

maui/src/NumericEntry/SfNumericEntry.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,8 +486,12 @@ protected override List<SemanticsNode> GetSemanticsNodesCore(double width, doubl
486486
{
487487
// Ensure any necessary size updates are performed
488488
UpdateSemanticsSizes();
489-
if (SemanticsDataIsCurrent() && IsTextInputLayout)
489+
if (SemanticsDataIsCurrent() || IsTextInputLayout)
490490
{
491+
if(IsTextInputLayout)
492+
{
493+
_numericEntrySemanticsNodes.Clear();
494+
}
491495
return _numericEntrySemanticsNodes;
492496
}
493497

maui/src/NumericEntry/SfNumericUpDown.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,6 +1142,10 @@ protected override List<SemanticsNode> GetSemanticsNodesCore(double width, doubl
11421142

11431143
if (SemanticsDataIsCurrent() || IsTextInputLayout)
11441144
{
1145+
if (IsTextInputLayout)
1146+
{
1147+
_numericUpDownSemanticsNodes.Clear();
1148+
}
11451149
return _numericUpDownSemanticsNodes;
11461150
}
11471151
var upbuttonstate = !(_valueStates == ValueStates.Maximum) || AutoReverse;

maui/src/TextInputLayout/SfTextInputLayout.Methods.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,23 @@ void ResetSemantics()
254254
}
255255
}
256256

257+
/// <summary>
258+
/// Resets semantics on first character input or when text is cleared.
259+
/// </summary>
260+
void HandleSemanticsReset()
261+
{
262+
if (string.IsNullOrEmpty(_text))
263+
{
264+
_hasResetSemantics = false;
265+
ResetSemantics();
266+
}
267+
else if (_text.Length == 1 && !_hasResetSemantics)
268+
{
269+
ResetSemantics();
270+
_hasResetSemantics = true;
271+
}
272+
}
273+
257274
/// <summary>
258275
/// Gets the button size based on the vertical alignment and icon templates.
259276
/// </summary>

maui/src/TextInputLayout/SfTextInputLayout.Properties.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1787,7 +1787,7 @@ internal set
17871787
if (value != _text)
17881788
{
17891789
_text = value;
1790-
ResetSemantics();
1790+
HandleSemanticsReset();
17911791
}
17921792
}
17931793
}
@@ -2160,9 +2160,9 @@ static void OnIsLayoutFocusedChanged(BindableObject bindable, object oldValue, o
21602160
{
21612161
if (bindable is SfTextInputLayout inputLayout)
21622162
{
2163-
inputLayout.ResetSemantics();
21642163
inputLayout.ChangeVisualState();
21652164
inputLayout.StartAnimation();
2165+
inputLayout.ResetSemantics();
21662166
}
21672167
}
21682168

maui/src/TextInputLayout/SfTextInputLayout.cs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,11 @@ public partial class SfTextInputLayout : SfContentView, ITouchListener, IParentT
292292
/// </summary>
293293
Size _controlSize = Size.Zero;
294294

295+
/// <summary>
296+
/// Indicates whether semantics need to be reset.
297+
/// </summary>
298+
bool _hasResetSemantics = false;
299+
295300
/// <summary>
296301
/// The field sets and checks the text.
297302
/// </summary>
@@ -700,7 +705,7 @@ void PopulateNumericSemanticsNodes(object? content)
700705
AddNumericUpDownNodes(numericUpDown);
701706
break;
702707
case SfNumericEntry when IsClearIconVisible:
703-
AddSemanticsNode(_clearIconRectF, 2, "Clear button");
708+
AddClearButtonNodes(2);
704709
break;
705710
}
706711
}
@@ -727,18 +732,28 @@ void AddUpDownNodes(SfNumericUpDown numericUpDown, bool isUpEnabled, bool isDown
727732

728733
if (addClearIconFirst && IsClearIconVisible)
729734
{
730-
AddSemanticsNode(_clearIconRectF, 2, "Clear button");
735+
AddClearButtonNodes(2);
731736
}
732737

733738
AddSemanticsNode(isVerticalInline ? _downIconRectF : _upIconRectF, addClearIconFirst ? 3 : 2, "Up button", isUpEnabled);
734739
AddSemanticsNode(isVerticalInline ? _upIconRectF : _downIconRectF, addClearIconFirst ? 4 : 3, "Down button", isDownEnabled);
735740

736741
if (!addClearIconFirst && IsClearIconVisible)
737742
{
738-
AddSemanticsNode(_clearIconRectF, 4, "Clear button");
743+
AddClearButtonNodes(4);
739744
}
740745
}
741746

747+
/// <summary>
748+
/// Adds a semantic node for clear button.
749+
/// </summary>
750+
void AddClearButtonNodes(int index)
751+
{
752+
var tempBounds = _clearIconRectF;
753+
tempBounds.Width = tempBounds.Height = IconSize;
754+
AddSemanticsNode(tempBounds, index, "Clear button");
755+
}
756+
742757
/// <summary>
743758
/// Adds a semantic node with specified properties.
744759
/// </summary>

0 commit comments

Comments
 (0)