Skip to content

Conversation

@devanathan-vaithiyanathan
Copy link
Contributor

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Issue Details

After PR #29234 , the else part was removed to stop the Navigated event from triggering when the WebView had no source.
However, this caused a new issue where rendering a WebView without a source exceeded the layout bounds.

Root Cause

When the WebView was rendered without a source, the layout logic was not properly handled — causing the WebView to exceed its layout bounds.

Description of Change

  • Reintroduced the else part.
  • Added a check to skip the Navigated event when the source is the default (empty).

This fix resolves both the layout overflow and unwanted event trigger issues.

Issues Fixed

Fixes #32030

Tested the behavior in the following platforms.

  • Android
  • Windows
  • iOS
  • Mac
Before After
Android
Android

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Oct 22, 2025
@dotnet-policy-service
Copy link
Contributor

Hey there @@devanathan-vaithiyanathan! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@dotnet-policy-service dotnet-policy-service bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Oct 22, 2025
@jsuarezruiz
Copy link
Contributor

/azp run MAUI-UITests-public

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

return false;

// Check if URL is about:blank (case insensitive)
return string.Equals(url.Trim(), "about:blank", StringComparison.OrdinalIgnoreCase);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could expand to more variants?

Examples:

  • "about:blank#"
  • "about:blank/"

Copy link
Contributor

Choose a reason for hiding this comment

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

This will be invoked on every Navigation. The impact on performance now is minimal for the current simple string comparison, but take this into account (for example, if think in use URI parsing or more complex stuff).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jsuarezruiz , When the source is null, we set the default WebView source to about:blank. As a result, the OnPageFinished method always receives about:blank as the parameter. Therefore, handling additional variants such as about:blank# or about:blank/ is not necessary in this case.
image

@sheiksyedm
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@devanathan-vaithiyanathan devanathan-vaithiyanathan marked this pull request as ready for review October 28, 2025 08:39
Copilot AI review requested due to automatic review settings October 28, 2025 08:39
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes an Android-specific issue where a WebView without a source would expand beyond its Grid cell boundaries. The fix reintroduces the else block that loads about:blank when there's no source, while preventing the Navigated event from firing for this default navigation.

  • Restores layout bounds handling by loading about:blank when WebView has no source
  • Adds filtering logic to suppress Navigated events for about:blank navigation
  • Includes UI test to verify WebView stays within Grid cell boundaries

Reviewed Changes

Copilot reviewed 4 out of 8 changed files in this pull request and generated 1 comment.

File Description
src/Core/src/Platform/Android/WebViewExtensions.cs Reintroduces else block to load about:blank when WebView has no source
src/Core/src/Platform/Android/MauiWebViewClient.cs Adds IsBlankNavigation helper and filters Navigated event for blank URLs
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue32030.cs Adds NUnit test to verify WebView layout behavior
src/Controls/tests/TestCases.HostApp/Issues/Issue32030.cs Adds test page demonstrating WebView in Grid without source
Comments suppressed due to low confidence (1)

src/Controls/tests/TestCases.HostApp/Issues/Issue32030.cs:1

  • Corrected spelling of 'it's' to 'its' in the issue description. 'Its' is the possessive form, while 'it's' means 'it is'.
namespace Maui.Controls.Sample.Issues;

Comment on lines +101 to +102
if (string.IsNullOrWhiteSpace(url))
return false;
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

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

The check IsNullOrWhiteSpace returns false for blank URLs, but the method is named IsBlankNavigation. This is counterintuitive - a null or whitespace URL could reasonably be considered 'blank'. Consider returning true for null/whitespace URLs, or rename the method to clarify its purpose (e.g., IsAboutBlankUrl).

Suggested change
if (string.IsNullOrWhiteSpace(url))
return false;
// Return true for null, empty, or whitespace URLs
if (string.IsNullOrWhiteSpace(url))
return true;

Copilot uses AI. Check for mistakes.

static bool IsBlankNavigation(string? url)
{
if (string.IsNullOrWhiteSpace(url))
Copy link
Contributor

Choose a reason for hiding this comment

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

if (navigate && !IsBlankNavigation(url))

Based on this:

  • url = null → IsBlankNavigation returns false → Navigated fires
  • url = "about:blank" → IsBlankNavigation returns true → Navigated doesn't fire

This could break the fix from #29234 which wanted to prevent events when Source is null

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-controls-webview WebView community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/android

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android - WebView in a grid expands beyond it's cell

3 participants