dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
21.96k stars 1.71k forks source link

macOS webview cannot open filedialog to upload file #19418

Open win4r opened 8 months ago

win4r commented 8 months ago

Description

macOS webview cannot open filedialog to upload file

Steps to Reproduce

No response

Link to public reproduction project repository

No response

Version with bug

8.0.3

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

6.0

Affected platforms

macOS

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

No response

win4r commented 8 months ago

you can test it use this link:https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_input_type_file

win4r commented 8 months ago
Screenshot 2023-12-14 at 8 45 33 PM
win4r commented 8 months ago

here is the code of maui:

public partial class MainPage : ContentPage
{
    int count = 0;

    public MainPage()
    {
        InitializeComponent();

        MyWebView.Source = "https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_input_type_file";
    }

}
Eilon commented 8 months ago

I seem to recall that this might be an issue with the native WebView on MacCatalyst, but I can't find any duplicate issues of it. I know we've had other cases where the MacCatalyst WebView simply didn't support certain things.

win4r commented 8 months ago

I seem to recall that this might be an issue with the native WebView on MacCatalyst, but I can't find any duplicate issues of it. I know we've had other cases where the MacCatalyst WebView simply didn't support certain things.

but in .net7,the webview is perfect

win4r commented 8 months ago

When I upgraded to .net8,This bug appears in webview

Eilon commented 8 months ago

@win4r oh sorry I missed that. Quite interesting. Is it all running on the same exact Mac machine, but just the app is using a different .NET version?

win4r commented 8 months ago

@win4r oh sorry I missed that. Quite interesting. Is it all running on the same exact Mac machine, but just the app is using a different .NET version?

yes.How to solve this bug?

win4r commented 8 months ago

I think this is the webview bug

ghost commented 8 months ago

Hi @win4r. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

PureWeen commented 8 months ago

If you can test with a catalyst app directly do you see the same issue?

dotnet new maccatalyst ?

win4r commented 8 months ago

Hi @win4r. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

I've pushed a sample project to GitHub, which you can find at https://github.com/win4r/maui-bug-report

This project is developed using .NET 8. In it, I've integrated a WebView component to load a specific URL. However, I encountered an issue: when I click the 'Choose File' button in the WebView, the file selection dialog fails to appear on macOS. image

PureWeen commented 8 months ago

If you can test with a catalyst app directly do you see the same issue?

dotnet new maccatalyst ?

Does this reproduce in a maccatalyst app? If so, then your best bet might be to ask on StackOverflow

ghost commented 8 months ago

Hi @win4r. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

win4r commented 8 months ago

maccatalyst

When I was using WebView with .NET 7, I didn't encounter this issue on macOS. However, after upgrading to .NET 8, I started experiencing problems with WebView. I believe this to be a bug in the WebView component within .NET 8.

davidortinau commented 7 months ago

This may be an Apple SDK change. .NET 7 is Mac Catalyst 16.x and .NET 8 is 17.x with the latest Xcode 15. Even though .NET 7 can build with Xcode 15, the SDK and bindings being used in .NET 7 are as described.

https://github.com/xamarin/xamarin-macios/releases

fyi @Eilon @PureWeen

win4r commented 7 months ago

This may be an Apple SDK change. .NET 7 is Mac Catalyst 16.x and .NET 8 is 17.x with the latest Xcode 15. Even though .NET 7 can build with Xcode 15, the SDK and bindings being used in .NET 7 are as described.

https://github.com/xamarin/xamarin-macios/releases

fyi @Eilon @PureWeen

how to repair?It's important for me,because my project includes webview

jaosnz-rep commented 5 months ago

Verified this issue with Visual Studio for Mac 17.6.9 build 415, can repro on .NET 8 macOS platform with sample project. https://github.com/win4r/maui-bug-report