From 8b6cc6040312d2b0ab174073034caeda1c0ebe87 Mon Sep 17 00:00:00 2001 From: Subhiksha Chandrasekaran Date: Wed, 8 Apr 2026 18:59:11 +0530 Subject: [PATCH 1/7] Fix for macCatalyst DatePicker Open and close events --- .../DatePickerHandler.MacCatalyst.cs | 87 +++++++++++++++---- 1 file changed, 68 insertions(+), 19 deletions(-) diff --git a/src/Core/src/Handlers/DatePicker/DatePickerHandler.MacCatalyst.cs b/src/Core/src/Handlers/DatePicker/DatePickerHandler.MacCatalyst.cs index bab10c33591b..a5f0a6aecf0a 100644 --- a/src/Core/src/Handlers/DatePicker/DatePickerHandler.MacCatalyst.cs +++ b/src/Core/src/Handlers/DatePicker/DatePickerHandler.MacCatalyst.cs @@ -8,6 +8,11 @@ namespace Microsoft.Maui.Handlers public partial class DatePickerHandler : ViewHandler { readonly UIDatePickerProxy _proxy = new(); + NSObject? _editingBeganObserver; + NSObject? _windowCloseObserver; + bool _isOpen; + + static readonly NSString NSWindowDidCloseNotification = new("NSWindowDidCloseNotification"); protected override UIDatePicker CreatePlatformView() { @@ -26,6 +31,18 @@ protected override void ConnectHandler(UIDatePicker platformView) platformView.Date = dt.ToNSDate(); } + // The compact UIDatePicker on MacCatalyst uses internal UITextField subviews + // for the date segments. Listen for any UITextField beginning editing — the + // IsDescendantOfView check ensures we only respond to our picker's fields. + _editingBeganObserver = NSNotificationCenter.DefaultCenter.AddObserver( + UITextField.TextDidBeginEditingNotification, OnEditingBegan); + + // On MacCatalyst the popover runs in an AppKit NSWindow. Tapping outside + // dismisses it at the AppKit level without firing UITextField EditingDidEnd, + // so NSWindowDidCloseNotification is needed for close. + _windowCloseObserver = NSNotificationCenter.DefaultCenter.AddObserver( + NSWindowDidCloseNotification, OnWindowClosed); + base.ConnectHandler(platformView); } @@ -33,9 +50,60 @@ protected override void DisconnectHandler(UIDatePicker platformView) { _proxy.Disconnect(platformView); + if (_editingBeganObserver is not null) + { + NSNotificationCenter.DefaultCenter.RemoveObserver(_editingBeganObserver); + _editingBeganObserver = null; + } + + if (_windowCloseObserver is not null) + { + NSNotificationCenter.DefaultCenter.RemoveObserver(_windowCloseObserver); + _windowCloseObserver = null; + } + + _isOpen = false; + base.DisconnectHandler(platformView); } + void OnEditingBegan(NSNotification notification) + { + if (_isOpen) + { + return; + } + + if (notification.Object is UITextField textField && textField.IsDescendantOfView(PlatformView)) + { + _isOpen = true; + if (VirtualView is IDatePicker virtualView) + { + virtualView.IsFocused = virtualView.IsOpen = true; + } + } + } + + void OnWindowClosed(NSNotification notification) + { + if (!_isOpen) + { + return; + } + + _isOpen = false; + + if (UpdateImmediately) + { + SetVirtualViewDate(); + } + + if (VirtualView is IDatePicker virtualView) + { + virtualView.IsFocused = virtualView.IsOpen = false; + } + } + public static partial void MapFormat(IDatePickerHandler handler, IDatePicker datePicker) { handler.PlatformView?.UpdateFormat(datePicker); @@ -102,15 +170,11 @@ public void Connect(DatePickerHandler handler, IDatePicker virtualView, UIDatePi _handler = new(handler); _virtualView = new(virtualView); - platformView.EditingDidBegin += OnStarted; - platformView.EditingDidEnd += OnEnded; platformView.ValueChanged += OnValueChanged; } public void Disconnect(UIDatePicker platformView) { - platformView.EditingDidBegin -= OnStarted; - platformView.EditingDidEnd -= OnEnded; platformView.ValueChanged -= OnValueChanged; } @@ -118,21 +182,6 @@ void OnValueChanged(object? sender, EventArgs? e) { if (_handler is not null && _handler.TryGetTarget(out var handler) && handler.UpdateImmediately) handler.SetVirtualViewDate(); - - if (VirtualView is IDatePicker virtualView) - virtualView.IsFocused = true; - } - - void OnStarted(object? sender, EventArgs eventArgs) - { - if (VirtualView is IDatePicker virtualView) - virtualView.IsFocused = true; - } - - void OnEnded(object? sender, EventArgs eventArgs) - { - if (VirtualView is IDatePicker virtualView) - virtualView.IsFocused = false; } } } From 10527f679263e51df9c859671b048ba175126734 Mon Sep 17 00:00:00 2001 From: Subhiksha Chandrasekaran Date: Wed, 8 Apr 2026 19:27:13 +0530 Subject: [PATCH 2/7] Fix using Recursive uiTextField. --- .../DatePickerHandler.MacCatalyst.cs | 56 ++++++++++++------- 1 file changed, 36 insertions(+), 20 deletions(-) diff --git a/src/Core/src/Handlers/DatePicker/DatePickerHandler.MacCatalyst.cs b/src/Core/src/Handlers/DatePicker/DatePickerHandler.MacCatalyst.cs index a5f0a6aecf0a..2135c36c5d4e 100644 --- a/src/Core/src/Handlers/DatePicker/DatePickerHandler.MacCatalyst.cs +++ b/src/Core/src/Handlers/DatePicker/DatePickerHandler.MacCatalyst.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using Foundation; using UIKit; using RectangleF = CoreGraphics.CGRect; @@ -8,8 +9,8 @@ namespace Microsoft.Maui.Handlers public partial class DatePickerHandler : ViewHandler { readonly UIDatePickerProxy _proxy = new(); - NSObject? _editingBeganObserver; NSObject? _windowCloseObserver; + readonly List _textFields = new(); bool _isOpen; static readonly NSString NSWindowDidCloseNotification = new("NSWindowDidCloseNotification"); @@ -32,16 +33,13 @@ protected override void ConnectHandler(UIDatePicker platformView) } // The compact UIDatePicker on MacCatalyst uses internal UITextField subviews - // for the date segments. Listen for any UITextField beginning editing — the - // IsDescendantOfView check ensures we only respond to our picker's fields. - _editingBeganObserver = NSNotificationCenter.DefaultCenter.AddObserver( - UITextField.TextDidBeginEditingNotification, OnEditingBegan); + // for the date segments. Wire up EditingDidBegin directly on those fields. + FindAndWireTextFields(platformView); // On MacCatalyst the popover runs in an AppKit NSWindow. Tapping outside // dismisses it at the AppKit level without firing UITextField EditingDidEnd, // so NSWindowDidCloseNotification is needed for close. - _windowCloseObserver = NSNotificationCenter.DefaultCenter.AddObserver( - NSWindowDidCloseNotification, OnWindowClosed); + _windowCloseObserver = NSNotificationCenter.DefaultCenter.AddObserver(NSWindowDidCloseNotification, OnWindowClosed); base.ConnectHandler(platformView); } @@ -50,11 +48,7 @@ protected override void DisconnectHandler(UIDatePicker platformView) { _proxy.Disconnect(platformView); - if (_editingBeganObserver is not null) - { - NSNotificationCenter.DefaultCenter.RemoveObserver(_editingBeganObserver); - _editingBeganObserver = null; - } + UnwireTextFields(); if (_windowCloseObserver is not null) { @@ -67,20 +61,42 @@ protected override void DisconnectHandler(UIDatePicker platformView) base.DisconnectHandler(platformView); } - void OnEditingBegan(NSNotification notification) + void FindAndWireTextFields(UIView view) + { + foreach (var subview in view.Subviews) + { + if (subview is UITextField textField) + { + textField.EditingDidBegin += OnEditingDidBegin; + _textFields.Add(textField); + } + else + { + FindAndWireTextFields(subview); + } + } + } + + void UnwireTextFields() + { + foreach (var textField in _textFields) + { + textField.EditingDidBegin -= OnEditingDidBegin; + } + _textFields.Clear(); + } + + void OnEditingDidBegin(object? sender, EventArgs e) { if (_isOpen) { return; } - if (notification.Object is UITextField textField && textField.IsDescendantOfView(PlatformView)) + _isOpen = true; + if (VirtualView is IDatePicker virtualView) { - _isOpen = true; - if (VirtualView is IDatePicker virtualView) - { - virtualView.IsFocused = virtualView.IsOpen = true; - } + virtualView.IsFocused = virtualView.IsOpen = true; } } @@ -185,4 +201,4 @@ void OnValueChanged(object? sender, EventArgs? e) } } } -} \ No newline at end of file +} From d688d7e7347304c1c61e353a55a21ec654c98a4c Mon Sep 17 00:00:00 2001 From: Subhiksha Chandrasekaran Date: Thu, 9 Apr 2026 13:06:07 +0530 Subject: [PATCH 3/7] Fixed UIdatePicker focused after close event --- .../DatePickerHandler.MacCatalyst.cs | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/Core/src/Handlers/DatePicker/DatePickerHandler.MacCatalyst.cs b/src/Core/src/Handlers/DatePicker/DatePickerHandler.MacCatalyst.cs index 2135c36c5d4e..5b30c822e468 100644 --- a/src/Core/src/Handlers/DatePicker/DatePickerHandler.MacCatalyst.cs +++ b/src/Core/src/Handlers/DatePicker/DatePickerHandler.MacCatalyst.cs @@ -61,6 +61,9 @@ protected override void DisconnectHandler(UIDatePicker platformView) base.DisconnectHandler(platformView); } + // Recursively searches the UIDatePicker's view hierarchy for internal + // UITextField subviews used by the compact date picker on MacCatalyst + // and subscribes to their editing events to track focus state. void FindAndWireTextFields(UIView view) { foreach (var subview in view.Subviews) @@ -118,6 +121,27 @@ void OnWindowClosed(NSNotification notification) { virtualView.IsFocused = virtualView.IsOpen = false; } + + // On MacCatalyst the internal UITextFields stay as first responder + // (visually highlighted) even after the popover window closes. + // EndEditing(true) on the parent view does not propagate to them, + // so we must directly resign each tracked text field on the next + // run-loop iteration (the notification fires before UIKit is ready). + ResignTextFields(); + } + + void ResignTextFields() + { + CoreFoundation.DispatchQueue.MainQueue.DispatchAsync(() => + { + foreach (var textField in _textFields) + { + if (textField.IsFirstResponder) + { + textField.ResignFirstResponder(); + } + } + }); } public static partial void MapFormat(IDatePickerHandler handler, IDatePicker datePicker) @@ -198,6 +222,9 @@ void OnValueChanged(object? sender, EventArgs? e) { if (_handler is not null && _handler.TryGetTarget(out var handler) && handler.UpdateImmediately) handler.SetVirtualViewDate(); + + if (VirtualView is IDatePicker virtualView) + virtualView.IsFocused = true; } } } From 8b912708475f646f6e120387ad6d82c7bdcffe37 Mon Sep 17 00:00:00 2001 From: Subhiksha Chandrasekaran Date: Fri, 10 Apr 2026 12:33:57 +0530 Subject: [PATCH 4/7] Optimised recursive method --- .../DatePickerHandler.MacCatalyst.cs | 54 +++++++++++-------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/src/Core/src/Handlers/DatePicker/DatePickerHandler.MacCatalyst.cs b/src/Core/src/Handlers/DatePicker/DatePickerHandler.MacCatalyst.cs index 5b30c822e468..940d0563d0e9 100644 --- a/src/Core/src/Handlers/DatePicker/DatePickerHandler.MacCatalyst.cs +++ b/src/Core/src/Handlers/DatePicker/DatePickerHandler.MacCatalyst.cs @@ -10,10 +10,7 @@ public partial class DatePickerHandler : ViewHandler { readonly UIDatePickerProxy _proxy = new(); NSObject? _windowCloseObserver; - readonly List _textFields = new(); - bool _isOpen; - - static readonly NSString NSWindowDidCloseNotification = new("NSWindowDidCloseNotification"); + bool _isDatePickerOpen; protected override UIDatePicker CreatePlatformView() { @@ -34,12 +31,12 @@ protected override void ConnectHandler(UIDatePicker platformView) // The compact UIDatePicker on MacCatalyst uses internal UITextField subviews // for the date segments. Wire up EditingDidBegin directly on those fields. - FindAndWireTextFields(platformView); + WireTextFields(platformView); // On MacCatalyst the popover runs in an AppKit NSWindow. Tapping outside // dismisses it at the AppKit level without firing UITextField EditingDidEnd, // so NSWindowDidCloseNotification is needed for close. - _windowCloseObserver = NSNotificationCenter.DefaultCenter.AddObserver(NSWindowDidCloseNotification, OnWindowClosed); + _windowCloseObserver = NSNotificationCenter.DefaultCenter.AddObserver(new("NSWindowDidCloseNotification"), OnWindowClosed); base.ConnectHandler(platformView); } @@ -48,7 +45,7 @@ protected override void DisconnectHandler(UIDatePicker platformView) { _proxy.Disconnect(platformView); - UnwireTextFields(); + UnwireTextFields(platformView); if (_windowCloseObserver is not null) { @@ -56,47 +53,57 @@ protected override void DisconnectHandler(UIDatePicker platformView) _windowCloseObserver = null; } - _isOpen = false; + _isDatePickerOpen = false; base.DisconnectHandler(platformView); } - // Recursively searches the UIDatePicker's view hierarchy for internal - // UITextField subviews used by the compact date picker on MacCatalyst - // and subscribes to their editing events to track focus state. - void FindAndWireTextFields(UIView view) + + // Recursively traverses the view hierarchy and yields all UITextField subviews. + // Used to find the internal text fields of the compact UIDatePicker on MacCatalyst. + static IEnumerable GetTextFields(UIView view) { foreach (var subview in view.Subviews) { + if (subview is UITextField textField) { - textField.EditingDidBegin += OnEditingDidBegin; - _textFields.Add(textField); + yield return textField; } else { - FindAndWireTextFields(subview); + foreach (var nested in GetTextFields(subview)) + { + yield return nested; + } } } } - void UnwireTextFields() + void WireTextFields(UIView view) + { + foreach (var textField in GetTextFields(view)) + { + textField.EditingDidBegin += OnEditingDidBegin; + } + } + + void UnwireTextFields(UIView view) { - foreach (var textField in _textFields) + foreach (var textField in GetTextFields(view)) { textField.EditingDidBegin -= OnEditingDidBegin; } - _textFields.Clear(); } void OnEditingDidBegin(object? sender, EventArgs e) { - if (_isOpen) + if (_isDatePickerOpen) { return; } - _isOpen = true; + _isDatePickerOpen = true; if (VirtualView is IDatePicker virtualView) { virtualView.IsFocused = virtualView.IsOpen = true; @@ -105,12 +112,12 @@ void OnEditingDidBegin(object? sender, EventArgs e) void OnWindowClosed(NSNotification notification) { - if (!_isOpen) + if (!_isDatePickerOpen) { return; } - _isOpen = false; + _isDatePickerOpen = false; if (UpdateImmediately) { @@ -132,9 +139,10 @@ void OnWindowClosed(NSNotification notification) void ResignTextFields() { + var platformView = PlatformView; CoreFoundation.DispatchQueue.MainQueue.DispatchAsync(() => { - foreach (var textField in _textFields) + foreach (var textField in GetTextFields(platformView)) { if (textField.IsFirstResponder) { From 27a08d8bae7a587d44557b98c8c841e88a7a7c2a Mon Sep 17 00:00:00 2001 From: Subhiksha Chandrasekaran Date: Tue, 14 Apr 2026 17:25:38 +0530 Subject: [PATCH 5/7] Test Sample added --- .../TestCases.HostApp/Issues/Issue34848.cs | 46 +++++++++++++++++++ .../Tests/Issues/Issue34848.cs | 42 +++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 src/Controls/tests/TestCases.HostApp/Issues/Issue34848.cs create mode 100644 src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue34848.cs diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue34848.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue34848.cs new file mode 100644 index 000000000000..2b49e1bb2134 --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue34848.cs @@ -0,0 +1,46 @@ +namespace Maui.Controls.Sample.Issues; + +[Issue(IssueTracker.Github, 34848, "DatePicker Opened and Closed events are not raised on MacCatalyst", PlatformAffected.macOS)] +public class Issue34848 : TestContentPage +{ + DatePicker _datePicker; + Label _OpenstatusLabel; + Label _ClosestatusLabel; + protected override void Init() + { + _OpenstatusLabel = new Label + { + AutomationId = "Issue34848OpenStatusLabel", + Text = "Opened: Unknown", + HorizontalOptions = LayoutOptions.Center + }; + + _ClosestatusLabel = new Label + { + AutomationId = "Issue34848CloseStatusLabel", + Text = "Closed: Unknown", + HorizontalOptions = LayoutOptions.Center + }; + + _datePicker = new DatePicker + { + AutomationId = "Issue34848TestDatePicker", + Date = DateTime.Today, + HorizontalOptions = LayoutOptions.Center + }; + + _datePicker.Opened += (s, e) => _OpenstatusLabel.Text = "Opened"; + _datePicker.Closed += (s, e) => _ClosestatusLabel.Text = "Closed"; + + Content = new VerticalStackLayout + { + Spacing = 10, + Children = + { + _OpenstatusLabel, + _ClosestatusLabel, + _datePicker + } + }; + } +} diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue34848.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue34848.cs new file mode 100644 index 000000000000..281af6d81a79 --- /dev/null +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue34848.cs @@ -0,0 +1,42 @@ +using System.Diagnostics; +using NUnit.Framework; +using UITest.Appium; +using UITest.Core; + +namespace Microsoft.Maui.TestCases.Tests.Issues; + +public class Issue34848 : _IssuesUITest +{ + public Issue34848(TestDevice testDevice) : base(testDevice) { } + + public override string Issue => "DatePicker Opened and Closed events are not raised on MacCatalyst"; + + [Test] + [Category(UITestCategories.DatePicker)] + public void DatePickerOpenedAndClosedEventsAreRaised() + { + App.WaitForElement("Issue34848OpenStatusLabel"); + App.WaitForElement("Issue34848CloseStatusLabel"); + App.WaitForElement("Issue34848TestDatePicker"); + + // Open the DatePicker + App.Tap("Issue34848TestDatePicker"); + +#if IOS + // iOS DatePicker uses a wheel picker, so we can just tap the "Done" button to close it + App.Tap("Done"); +#elif WINDOWS + // On Windows, we can tap a date to close the DatePicker + App.Tap("16"); +#elif ANDROID + // On Android, we can tap the "Cancel" button to close the DatePicker + App.Tap("Cancel"); +#else + // On MacCatalyst, we can tap outside the DatePicker to close it + App.TapCoordinates(30, 30); +#endif + + Assert.That(App.WaitForElement("Issue34848OpenStatusLabel").GetText(), Is.EqualTo("Opened")); + Assert.That(App.WaitForElement("Issue34848CloseStatusLabel").GetText(), Is.EqualTo("Closed")); + } +} From 846faa466a4cb5832c8d2cfd5fbe116779bff946 Mon Sep 17 00:00:00 2001 From: Subhiksha Chandrasekaran Date: Wed, 15 Apr 2026 13:54:49 +0530 Subject: [PATCH 6/7] modified observer changes --- .../DatePickerHandler.MacCatalyst.cs | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Core/src/Handlers/DatePicker/DatePickerHandler.MacCatalyst.cs b/src/Core/src/Handlers/DatePicker/DatePickerHandler.MacCatalyst.cs index 940d0563d0e9..1a49a154100d 100644 --- a/src/Core/src/Handlers/DatePicker/DatePickerHandler.MacCatalyst.cs +++ b/src/Core/src/Handlers/DatePicker/DatePickerHandler.MacCatalyst.cs @@ -33,11 +33,6 @@ protected override void ConnectHandler(UIDatePicker platformView) // for the date segments. Wire up EditingDidBegin directly on those fields. WireTextFields(platformView); - // On MacCatalyst the popover runs in an AppKit NSWindow. Tapping outside - // dismisses it at the AppKit level without firing UITextField EditingDidEnd, - // so NSWindowDidCloseNotification is needed for close. - _windowCloseObserver = NSNotificationCenter.DefaultCenter.AddObserver(new("NSWindowDidCloseNotification"), OnWindowClosed); - base.ConnectHandler(platformView); } @@ -104,6 +99,14 @@ void OnEditingDidBegin(object? sender, EventArgs e) } _isDatePickerOpen = true; + + // Register a one-shot observer scoped to this picker's open lifetime. + // On MacCatalyst the popover runs in an AppKit NSWindow; tapping outside + // dismisses it at the AppKit level without firing UITextField EditingDidEnd. + // Registering here (not in ConnectHandler) avoids spurious fires from + // unrelated window closes while the picker is not open. + _windowCloseObserver = NSNotificationCenter.DefaultCenter.AddObserver(new("NSWindowDidCloseNotification"), OnWindowClosed); + if (VirtualView is IDatePicker virtualView) { virtualView.IsFocused = virtualView.IsOpen = true; @@ -112,18 +115,15 @@ void OnEditingDidBegin(object? sender, EventArgs e) void OnWindowClosed(NSNotification notification) { - if (!_isDatePickerOpen) + // One-shot: remove the observer immediately so it won't fire again. + if (_windowCloseObserver is not null) { - return; + NSNotificationCenter.DefaultCenter.RemoveObserver(_windowCloseObserver); + _windowCloseObserver = null; } _isDatePickerOpen = false; - if (UpdateImmediately) - { - SetVirtualViewDate(); - } - if (VirtualView is IDatePicker virtualView) { virtualView.IsFocused = virtualView.IsOpen = false; From fe3199df2f03b2f3f7cb13af9aa6efde69ec42f4 Mon Sep 17 00:00:00 2001 From: Subhiksha Chandrasekaran Date: Thu, 16 Apr 2026 14:15:49 +0530 Subject: [PATCH 7/7] Updated sugggestion --- .../tests/TestCases.HostApp/Issues/Issue34848.cs | 16 ++++++++-------- .../Tests/Issues/Issue34848.cs | 1 - .../DatePicker/DatePickerHandler.MacCatalyst.cs | 4 +++- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue34848.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue34848.cs index 2b49e1bb2134..cac2eb474458 100644 --- a/src/Controls/tests/TestCases.HostApp/Issues/Issue34848.cs +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue34848.cs @@ -4,18 +4,18 @@ namespace Maui.Controls.Sample.Issues; public class Issue34848 : TestContentPage { DatePicker _datePicker; - Label _OpenstatusLabel; - Label _ClosestatusLabel; + Label _openStatusLabel; + Label _closeStatusLabel; protected override void Init() { - _OpenstatusLabel = new Label + _openStatusLabel = new Label { AutomationId = "Issue34848OpenStatusLabel", Text = "Opened: Unknown", HorizontalOptions = LayoutOptions.Center }; - _ClosestatusLabel = new Label + _closeStatusLabel = new Label { AutomationId = "Issue34848CloseStatusLabel", Text = "Closed: Unknown", @@ -29,16 +29,16 @@ protected override void Init() HorizontalOptions = LayoutOptions.Center }; - _datePicker.Opened += (s, e) => _OpenstatusLabel.Text = "Opened"; - _datePicker.Closed += (s, e) => _ClosestatusLabel.Text = "Closed"; + _datePicker.Opened += (s, e) => _openStatusLabel.Text = "Opened"; + _datePicker.Closed += (s, e) => _closeStatusLabel.Text = "Closed"; Content = new VerticalStackLayout { Spacing = 10, Children = { - _OpenstatusLabel, - _ClosestatusLabel, + _openStatusLabel, + _closeStatusLabel, _datePicker } }; diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue34848.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue34848.cs index 281af6d81a79..11e5469f91ff 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue34848.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue34848.cs @@ -1,4 +1,3 @@ -using System.Diagnostics; using NUnit.Framework; using UITest.Appium; using UITest.Core; diff --git a/src/Core/src/Handlers/DatePicker/DatePickerHandler.MacCatalyst.cs b/src/Core/src/Handlers/DatePicker/DatePickerHandler.MacCatalyst.cs index 1a49a154100d..ba3b2f5ef486 100644 --- a/src/Core/src/Handlers/DatePicker/DatePickerHandler.MacCatalyst.cs +++ b/src/Core/src/Handlers/DatePicker/DatePickerHandler.MacCatalyst.cs @@ -8,6 +8,8 @@ namespace Microsoft.Maui.Handlers { public partial class DatePickerHandler : ViewHandler { + static readonly NSString WindowDidCloseNotification = new("NSWindowDidCloseNotification"); + readonly UIDatePickerProxy _proxy = new(); NSObject? _windowCloseObserver; bool _isDatePickerOpen; @@ -105,7 +107,7 @@ void OnEditingDidBegin(object? sender, EventArgs e) // dismisses it at the AppKit level without firing UITextField EditingDidEnd. // Registering here (not in ConnectHandler) avoids spurious fires from // unrelated window closes while the picker is not open. - _windowCloseObserver = NSNotificationCenter.DefaultCenter.AddObserver(new("NSWindowDidCloseNotification"), OnWindowClosed); + _windowCloseObserver = NSNotificationCenter.DefaultCenter.AddObserver(WindowDidCloseNotification, OnWindowClosed); if (VirtualView is IDatePicker virtualView) {