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
22.21k stars 1.75k forks source link

Datepicker focus and unfocus event not firing on android #18797

Open Eves101 opened 12 months ago

Eves101 commented 12 months ago

Description

Datepicker focus and unfocus event are not firing on android, but they do on windows machine.

Steps to Reproduce

Create default maui app add datepicker add focus/unfocus events start android emulator watch breakpoints not hit on events

Link to public reproduction project repository

https://github.com/Eves101/DatepickerFocusIssueAndroid

Version with bug

8.0.3

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

No response

XamlTest commented 11 months ago

Verified this on Visual Studio Enterprise 17.9.0 Preview 1(8.0.3). Repro on Android 14.0-API34 and MacCatalyst, not repro on Windows 11 and iOS 17.0 with below Project: DatepickerFocusIssue.zip

ghost commented 11 months ago

We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.

gerhartz commented 6 months ago

What worked for me was extending the Maui DatePicker into my own date picker that has a single method Open()

Connect the tap gesture in the date picker to call Open()

void Open() {

      #if ANDROID
                  if (this.Handler is IDatePickerHandler handler) {
                      handler.PlatformView.PerformClick();
                  }
      #else
                  (this as IView).IsFocused = false;
                  this.Focus();
      #endif
}
danbrannanavontus commented 2 months ago

Is there any update on this? It still isn't working in the latest version of Maui as of 13/08/24

brinawebb commented 2 months ago

Supposedly there's a fix but it's stuck in review. Maui team, can you please review/accept the pull? We're converting from Xamarin and this bug is preventing us from doing so.

ryanaw83 commented 2 months ago

This fix is needed... will it be fixed soon?

guyvaio commented 1 month ago

Also waiting for this fix...

mknotzer commented 3 weeks ago

after almost one year still not fixed!

my workaround:

private DatePickerDialog mDialog;

protected override DatePickerDialog CreateDatePickerDialog(int year, int month, int day)
{
    mDialog = base.CreateDatePickerDialog(year, month, day);

    return mDialog;
}

protected override void ConnectHandler(MauiDatePicker platformView)
{
    base.ConnectHandler(platformView);

    mDialog.ShowEvent += OnDialogShown;
    mDialog.DismissEvent += OnDialogDismissed;
}

private void OnDialogShown(object sender, EventArgs e)
{
    VirtualView.IsFocused = true;
}

private void OnDialogDismissed(object sender, EventArgs e)
{
    VirtualView.IsFocused = false;
}