From 97d0c81c39ae8648394339fa2d653bcbd89e2e6d Mon Sep 17 00:00:00 2001 From: devanathan-vaithiyanathan <114395405+devanathan-vaithiyanathan@users.noreply.github.com> Date: Mon, 23 Jun 2025 13:01:17 +0530 Subject: [PATCH 1/5] fix added --- src/Core/src/Platform/Windows/DatePickerExtensions.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Core/src/Platform/Windows/DatePickerExtensions.cs b/src/Core/src/Platform/Windows/DatePickerExtensions.cs index 839fc8d9a4af..3800866cfb6e 100644 --- a/src/Core/src/Platform/Windows/DatePickerExtensions.cs +++ b/src/Core/src/Platform/Windows/DatePickerExtensions.cs @@ -55,7 +55,15 @@ public static void UpdateMaximumDate(this CalendarDatePicker platformDatePicker, public static void UpdateCharacterSpacing(this CalendarDatePicker platformDatePicker, IDatePicker datePicker) { - platformDatePicker.CharacterSpacing = datePicker.CharacterSpacing.ToEm(); + var characterSpacing = datePicker.CharacterSpacing.ToEm(); + platformDatePicker.CharacterSpacing = characterSpacing; + + var dateTextBlock = platformDatePicker.GetDescendantByName("DateText"); + if (dateTextBlock is not null) + { + dateTextBlock.CharacterSpacing = characterSpacing; + dateTextBlock.RefreshThemeResources(); + } } public static void UpdateFont(this CalendarDatePicker platformDatePicker, IDatePicker datePicker, IFontManager fontManager) => From 1f79febef09039c7c9eb16b4388fbffb9650b71d Mon Sep 17 00:00:00 2001 From: devanathan-vaithiyanathan <114395405+devanathan-vaithiyanathan@users.noreply.github.com> Date: Mon, 23 Jun 2025 13:02:12 +0530 Subject: [PATCH 2/5] Revert "fix added" This reverts commit 138797f06454b88d91cc6e868bace6e15a2101ed. --- src/Core/src/Platform/Windows/DatePickerExtensions.cs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/Core/src/Platform/Windows/DatePickerExtensions.cs b/src/Core/src/Platform/Windows/DatePickerExtensions.cs index 3800866cfb6e..839fc8d9a4af 100644 --- a/src/Core/src/Platform/Windows/DatePickerExtensions.cs +++ b/src/Core/src/Platform/Windows/DatePickerExtensions.cs @@ -55,15 +55,7 @@ public static void UpdateMaximumDate(this CalendarDatePicker platformDatePicker, public static void UpdateCharacterSpacing(this CalendarDatePicker platformDatePicker, IDatePicker datePicker) { - var characterSpacing = datePicker.CharacterSpacing.ToEm(); - platformDatePicker.CharacterSpacing = characterSpacing; - - var dateTextBlock = platformDatePicker.GetDescendantByName("DateText"); - if (dateTextBlock is not null) - { - dateTextBlock.CharacterSpacing = characterSpacing; - dateTextBlock.RefreshThemeResources(); - } + platformDatePicker.CharacterSpacing = datePicker.CharacterSpacing.ToEm(); } public static void UpdateFont(this CalendarDatePicker platformDatePicker, IDatePicker datePicker, IFontManager fontManager) => From eedff980ced76865c810e106e81c798c730d9a03 Mon Sep 17 00:00:00 2001 From: devanathan-vaithiyanathan <114395405+devanathan-vaithiyanathan@users.noreply.github.com> Date: Mon, 14 Jul 2025 13:06:23 +0530 Subject: [PATCH 3/5] fix added --- .../src/Platform/iOS/WebViewExtensions.cs | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/Core/src/Platform/iOS/WebViewExtensions.cs b/src/Core/src/Platform/iOS/WebViewExtensions.cs index 7f4a5c748bb1..bb4b2a9ea2f3 100644 --- a/src/Core/src/Platform/iOS/WebViewExtensions.cs +++ b/src/Core/src/Platform/iOS/WebViewExtensions.cs @@ -56,7 +56,27 @@ public static void UpdateGoForward(this WKWebView platformWebView, IWebView webV public static void UpdateReload(this WKWebView platformWebView, IWebView webView) { - platformWebView?.Reload(); + //platformWebView?.Reload(); + if (platformWebView == null) + return; + + // Check if we have a source and platformWebView implements IWebViewDelegate + if (webView.Source != null && platformWebView is IWebViewDelegate webViewDelegate) + { + // If the source is an HTML source, we need to reload from the source + // since WKWebView.Reload() doesn't work properly with LoadHtmlString + var sourceType = webView.Source.GetType().Name; + if (sourceType == "HtmlWebViewSource") + { + // For HTML sources, always reload from the source + webView.Source.Load(webViewDelegate); + } + else + { + // For URL sources, use the standard reload + platformWebView.Reload(); + } + } } internal static void UpdateCanGoBackForward(this WKWebView platformWebView, IWebView webView) From 926f7409b01f480b10de5afedaa084b8e2e8ebe5 Mon Sep 17 00:00:00 2001 From: devanathan-vaithiyanathan <114395405+devanathan-vaithiyanathan@users.noreply.github.com> Date: Tue, 15 Jul 2025 16:09:18 +0530 Subject: [PATCH 4/5] test case added --- .../TestCases.HostApp/Issues/Issue30515.cs | 135 ++++++++++++++++++ .../Tests/Issues/Issue30515.cs | 23 +++ .../src/Platform/iOS/WebViewExtensions.cs | 6 +- 3 files changed, 163 insertions(+), 1 deletion(-) create mode 100644 src/Controls/tests/TestCases.HostApp/Issues/Issue30515.cs create mode 100644 src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30515.cs diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue30515.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue30515.cs new file mode 100644 index 000000000000..1bbf8a89421e --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue30515.cs @@ -0,0 +1,135 @@ +namespace Maui.Controls.Sample.Issues; + +[Issue(IssueTracker.Github, 30515, "[iOS] WebView.Reload() with HtmlWebViewSource returns WebNavigationResult.Failure in Navigated event", PlatformAffected.iOS)] +public class Issue30515 : ContentPage +{ + WebView webView; + Label statusTextLabel; + Label statusValueLabel; + + public Issue30515() + { + Title = "Issue 30515"; + + // Create the navigation status labels - split into static text and dynamic value + statusTextLabel = new Label + { + Text = "Status:", + FontSize = 14, + TextColor = Colors.Gray, + VerticalOptions = LayoutOptions.Center + }; + + statusValueLabel = new Label + { + Text = "Ready", + AutomationId = "NavigationStatusLabel", + FontSize = 14, + TextColor = Colors.Blue, + VerticalOptions = LayoutOptions.Center + }; + + // Create a horizontal stack for the status display + var statusContainer = new StackLayout + { + Orientation = StackOrientation.Horizontal, + Spacing = 5, + HorizontalOptions = LayoutOptions.Center, + Children = { statusTextLabel, statusValueLabel } + }; + + // Create the WebView + webView = new WebView + { + HeightRequest = 300, + WidthRequest = 400, + Source = new HtmlWebViewSource + { + Html = @" + + + HTML WebView Source + + +

WebView Feature Matrix

+

This page demonstrates various capabilities of the .NET MAUI WebView control, such as:

+ +

Test Content

+

+ This is a longer body paragraph to help test the EvaluateJavaScript functionality + and how it extracts body text. You can use this text to verify substring operations and test scrolling + or formatting in the WebView. + +

+

+ Try interacting with navigation buttons, loading multiple pages, or checking cookie behavior. +

+ +

Navigation Test Links

+

Click these links to test URL navigation:

+ + + + + " + } + }; + + // Set up event handlers + webView.Navigated += OnWebViewNavigated; + + // Create the reload button + var reloadButton = new Button + { + Text = "Reload", + AutomationId = "ReloadButton", + HorizontalOptions = LayoutOptions.Center + }; + reloadButton.Clicked += OnReloadClicked; + + // Add all elements to the page + Content = new StackLayout + { + Padding = new Thickness(10), + Spacing = 10, + Children = + { + statusContainer, + webView, + new StackLayout + { + Orientation = StackOrientation.Horizontal, + Spacing = 10, + HorizontalOptions = LayoutOptions.Center, + Children = + { + reloadButton + } + } + } + }; + } + + void OnReloadClicked(object sender, EventArgs e) + { + statusValueLabel.Text = "Reloading..."; + webView.Reload(); + } + + void OnWebViewNavigated(object sender, WebNavigatedEventArgs e) + { + statusValueLabel.Text = e.Result.ToString(); + statusValueLabel.TextColor = Colors.Green; + } +} \ No newline at end of file diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30515.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30515.cs new file mode 100644 index 000000000000..44d90073c08f --- /dev/null +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30515.cs @@ -0,0 +1,23 @@ +using NUnit.Framework; +using UITest.Appium; +using UITest.Core; + +namespace Microsoft.Maui.TestCases.Tests.Issues; + +public class Issue30515 : _IssuesUITest +{ + public override string Issue => "[iOS] WebView.Reload() with HtmlWebViewSource returns WebNavigationResult.Failure in Navigated event"; + + public Issue30515(TestDevice device) + : base(device) + { } + + [Test] + [Category(UITestCategories.WebView)] + public void VerifyWebViewHTMLSourceReloadStatus() + { + App.WaitForElement("NavigationStatusLabel"); + App.Tap("ReloadButton"); + Assert.That(App.FindElement("NavigationStatusLabel").GetText(), Is.EqualTo("Success")); + } +} \ No newline at end of file diff --git a/src/Core/src/Platform/iOS/WebViewExtensions.cs b/src/Core/src/Platform/iOS/WebViewExtensions.cs index bb4b2a9ea2f3..ae5a9d867ff2 100644 --- a/src/Core/src/Platform/iOS/WebViewExtensions.cs +++ b/src/Core/src/Platform/iOS/WebViewExtensions.cs @@ -66,7 +66,7 @@ public static void UpdateReload(this WKWebView platformWebView, IWebView webView // If the source is an HTML source, we need to reload from the source // since WKWebView.Reload() doesn't work properly with LoadHtmlString var sourceType = webView.Source.GetType().Name; - if (sourceType == "HtmlWebViewSource") + if (string.Equals(sourceType, "HtmlWebViewSource", StringComparison.Ordinal)) { // For HTML sources, always reload from the source webView.Source.Load(webViewDelegate); @@ -77,6 +77,10 @@ public static void UpdateReload(this WKWebView platformWebView, IWebView webView platformWebView.Reload(); } } + else + { + platformWebView.Reload(); + } } internal static void UpdateCanGoBackForward(this WKWebView platformWebView, IWebView webView) From 50404841c1121e674113fdccd7cd106ab18f3406 Mon Sep 17 00:00:00 2001 From: devanathan-vaithiyanathan <114395405+devanathan-vaithiyanathan@users.noreply.github.com> Date: Tue, 15 Jul 2025 16:14:49 +0530 Subject: [PATCH 5/5] fix updated --- src/Core/src/Platform/iOS/WebViewExtensions.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Core/src/Platform/iOS/WebViewExtensions.cs b/src/Core/src/Platform/iOS/WebViewExtensions.cs index ae5a9d867ff2..3236c0dc3185 100644 --- a/src/Core/src/Platform/iOS/WebViewExtensions.cs +++ b/src/Core/src/Platform/iOS/WebViewExtensions.cs @@ -56,9 +56,10 @@ public static void UpdateGoForward(this WKWebView platformWebView, IWebView webV public static void UpdateReload(this WKWebView platformWebView, IWebView webView) { - //platformWebView?.Reload(); if (platformWebView == null) + { return; + } // Check if we have a source and platformWebView implements IWebViewDelegate if (webView.Source != null && platformWebView is IWebViewDelegate webViewDelegate)