[Windows] Fixed the issue with SearchBar focus and unfocus events.#28529
[Windows] Fixed the issue with SearchBar focus and unfocus events.#28529rmarinho merged 2 commits intodotnet:mainfrom
Conversation
|
Hey there @Ahamed-Ali! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
mattleibow
left a comment
There was a problem hiding this comment.
I know you are not done yet, but we do lose the logic in the UpdateIsFocused method in the manager. Maybe that method should be private protected and we use that?
Yes, I have now utilized |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
| // However, for AutoSuggestBox, when handling the GotFocus or LostFocus methods, tapping the AutoSuggestBox causes e.NewFocusedElement and e.OldFocusedElement to be a TextBox (which receives the focus). | ||
| // As a result, when comparing the PlatformView with the appropriate handler in FocusManagerMapping, the condition is not satisfied, causing the focus and unfocus methods to not work correctly. | ||
| // To address this, I have specifically handled the focus and unfocus events for AutoSuggestBox here. | ||
| platformView.GotFocus += OnGotFocus; |
There was a problem hiding this comment.
Good comment!
I was wondering if we could improve the logic in ViewHandler.Windows to manage the focus, and if comparing also based on derived types would make sense, even though AutoSuggestBox doesn't derive from Textbox (it does from ItemsControl). So, I think changes are fine.
Root Cause of the issue
ViewHandler.Windows,FocusManager.GotFocus and LostFocus are handled for other controls. However, forAutoSuggestBox, when handling the GotFocus or LostFocus methods, tapping the AutoSuggestBox causes e.NewFocusedElement and e.OldFocusedElement to be aTextBox(which is the ControlTemplate of AutoSuggestBox and receives the focus). As a result, when comparing the PlatformView with the appropriate handler inFocusManagerMapping, the condition is not satisfied, causing the focus and unfocus events to not work correctly.Description of Change
SearchBarHandler.Windows.Regressed PR
FocusManager(take 2) #24695Issues Fixed
Fixes #28419
Tested the behaviour in the following platforms
Screenshot
SearchBarIssueVideo.mp4
SearchBarFixVideo.mp4