Skip to content
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
eb2f05e
fix and UI test added
devanathan-vaithiyanathan Oct 17, 2024
1f0634e
Merge branch 'main' of https://github.com/devanathan-vaithiyanathan/m…
devanathan-vaithiyanathan Oct 22, 2024
7d5e245
review changes added
devanathan-vaithiyanathan Oct 23, 2024
57d3160
WinUI snap added
devanathan-vaithiyanathan Oct 24, 2024
9051718
fix and UI test added
devanathan-vaithiyanathan Oct 17, 2024
71f1e97
review changes added
devanathan-vaithiyanathan Oct 23, 2024
e889545
WinUI snap added
devanathan-vaithiyanathan Oct 24, 2024
08a9063
fail on mac removed
devanathan-vaithiyanathan Oct 25, 2024
d32064a
conflicts resolved
devanathan-vaithiyanathan Oct 25, 2024
903ca51
modified a test case
devanathan-vaithiyanathan Oct 30, 2024
80c9ca7
Removed-TestCases-Failure-Snap
prakashKannanSf3972 Oct 30, 2024
11618d2
Modified-TestCases
prakashKannanSf3972 Oct 30, 2024
2c637bb
Added-KeyBoard-Hide-Function.
prakashKannanSf3972 Nov 5, 2024
6003463
Added-SnapShots
prakashKannanSf3972 Nov 6, 2024
b0d9c0c
Added-iOS-SnapShot
prakashKannanSf3972 Nov 6, 2024
c464a59
Merge branch 'dotnet:main' into fix-17782
prakashKannanSf3972 Dec 6, 2024
f233d1f
Updated-Android-SnapShot
prakashKannanSf3972 Dec 9, 2024
4b9074c
Revert "Fixed CollectionViewHandler2 null reference exception if Item…
devanathan-vaithiyanathan Jan 8, 2025
92a1c94
Reapply "Fixed CollectionViewHandler2 null reference exception if Ite…
devanathan-vaithiyanathan Jan 8, 2025
53764a1
Merge branch 'dotnet:main' into main
devanathan-vaithiyanathan Jan 10, 2025
7666e57
Merge branch 'dotnet:main' into main
devanathan-vaithiyanathan Jan 15, 2025
19d79a6
Merge branch 'dotnet:main' into main
devanathan-vaithiyanathan Jan 16, 2025
01b9d40
Removed-Mac-TestCase-Failing-Code
prakashKannanSf3972 Jan 17, 2025
fce9a9a
Merge branch 'dotnet:main' into main
devanathan-vaithiyanathan Jan 20, 2025
a78d07a
Merge branch 'main' into fix-17782
prakashKannanSf3972 Jan 22, 2025
b9fa465
Added-Mac-Snapshot
prakashKannanSf3972 Jan 22, 2025
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
3 changes: 3 additions & 0 deletions src/Controls/src/Core/Editor/Editor.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ public static void MapText(EditorHandler handler, Editor editor) =>
public static void MapText(IEditorHandler handler, Editor editor)
{
Platform.TextExtensions.UpdateText(handler.PlatformView, editor);

// Any text changes in the editor field require recalculating the CharacterSpacing by regenerating the attributed string to properly apply the spacing and override the current text formatting.
handler?.UpdateValue(nameof(CharacterSpacing));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The fix looks good but, trying to understand why is necessary because is something we already are doing.

In the EditorHandler, updating the Text property we are invoking the MapFormatting method:

MapFormatting(handler, editor);

Where update the CharacterSpacing after set the text:

handler.PlatformView?.UpdateCharacterSpacing(editor);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@jsuarezruiz,

Since, we are remapping in editor text Property, which directly calls Editor.iOS MapText on text changes instead of MapText in EntryHandler.iOS. So, the MapText function in EntryHandler.iOS is not invoked whenever text changes.

image

Additionally, we’re already handling MaxLength in UpdateText, so there’s no need to update UpdateMaxLength through MapFormatting, as we ensure the length limitation within UpdateText itself. By doing this, the MapText method remains efficient and prevents unnecessary reprocessing, focusing solely on applying changes relevant to CharacterSpacing.

if (maxLength >= 0 && platformText.Length > maxLength)
platformText = platformText.Substring(0, maxLength);

}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
65 changes: 65 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue17782.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Maui.Controls.Sample.Issues.Issue17782"
xmlns:ns="clr-namespace:Maui.Controls.Sample.Issues"
Title="Issue 17782">

<VerticalStackLayout x:Name="verticalStack" Spacing="10">

<!-- Case 1: Add text to the editor with initial CharacterSpacing set to 10.
The Button click updates the text to a predefined value. -->
<Editor x:Name="initialCharacterSpacingEditor"
AutomationId="InitialCharacterSpacingEditor"
CharacterSpacing="10"
HeightRequest="60"/>

<Button x:Name="buttonAddEditorText"
AutomationId="ButtonAddEditorText"
Text="Click to Add Editor Text"
Clicked="OnAddEditorTextClicked"
HorizontalOptions="Fill" />

<!-- Case 2: Update CharacterSpacing of the editor programmatically.
Initially, the CharacterSpacing is not set, and upon clicking the button, it is updated to 10. -->
<Editor x:Name="dynamicCharacterSpacingEditor"
AutomationId="DynamicCharacterSpacingEditor"
HeightRequest="60" />

<Button x:Name="buttonUpdateCharacterSpacing"
AutomationId="ButtonUpdateCharacterSpacing"
Text="Update Dynamic Character Spacing"
Clicked="OnUpdateCharacterSpacingClicked" />

<!-- Case 3: Reset CharacterSpacing of the editor to zero.
Initially, the CharacterSpacing is set to 10, and the Button click resets it to 0. -->
<Editor x:Name="resetCharacterSpacingEditor"
AutomationId="ResetCharacterSpacingEditor"
CharacterSpacing="10"
HeightRequest="60" />

<Button x:Name="buttonResetCharacterSpacing"
AutomationId="ButtonResetCharacterSpacing"
Text="Reset Character Spacing"
Clicked="OnResetCharacterSpacingClicked" />

<!-- Case 4: Bind CharacterSpacing of the editor to a Slider's value.
The Slider allows dynamic adjustment of the editor's CharacterSpacing in real-time. -->
<Editor x:Name="editorWithSlider"
AutomationId="EditorWithSlider"
Text="Editor"
CharacterSpacing="{Binding Value}"
BindingContext="{x:Reference Slider}" />

<Slider x:Name="Slider"
AutomationId="SliderCharacterSpacing"
Minimum="0"
Maximum="30"
Value="10" />

<Button AutomationId="EditorsUnfocusButton"
Text="Set Editors Unfocus"
Clicked="OnEditorsUnfocusButtonClicked" />
</VerticalStackLayout>

</ContentPage>
39 changes: 39 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue17782.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System.Collections.ObjectModel;

namespace Maui.Controls.Sample.Issues
{

[Issue(IssueTracker.Github, 17782, "[ManualMauiTests] New text in the Editor character spacing test sometimes uses the previous spacing", PlatformAffected.iOS)]
public partial class Issue17782 : ContentPage
{

public Issue17782()
{
InitializeComponent();
}

private void OnAddEditorTextClicked(object sender, EventArgs e)
{
initialCharacterSpacingEditor.Text = "Initial CharacterSpacing with Text";
}

private void OnUpdateCharacterSpacingClicked(object sender, EventArgs e)
{
dynamicCharacterSpacingEditor.CharacterSpacing = 10;
}

private void OnResetCharacterSpacingClicked(object sender, EventArgs e)
{
resetCharacterSpacingEditor.CharacterSpacing = 0;
}

private void OnEditorsUnfocusButtonClicked(object sender, EventArgs e)
{
foreach(var child in verticalStack.Children)
{
if(child is Editor editor)
editor.Unfocus();
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#if !MACCATALYST
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Issue17782 : _IssuesUITest
{
public Issue17782(TestDevice testDevice) : base(testDevice)
{
}

public override string Issue => "[ManualMauiTests] New text in the Editor character spacing test sometimes uses the previous spacing";

[Test]
[Category(UITestCategories.Editor)]
public void VerifyEditorCharacterSpacingWithText()
{
App.WaitForElement("SliderCharacterSpacing");
App.Click("ButtonAddEditorText");
App.Click("ButtonUpdateCharacterSpacing");
App.EnterText("DynamicCharacterSpacingEditor", "Text");
App.Click("ButtonResetCharacterSpacing");
App.EnterText("ResetCharacterSpacingEditor", "Text");
App.Click("EditorsUnfocusButton");
#if IOS
App.DismissKeyboard();
#endif
VerifyScreenshot();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The test is failing on iOS. Next, a screenshot where can see the differences (red):
image

Can use the App.DismissKeyboard() method to close the virtual keyboard if want to avoid it in the snapshot.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thank you for the feedback. We observed successful image generation during our testing. The discrepancies might stem from version differences between the emulator and simulator environments in CI.As per your suggestion added App.DismissKeyboard().

}
}
#endif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.