Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

#7956 [Shell] Unable to focus and unfocus search handler for Android #14375

Closed
wants to merge 11 commits into from

Conversation

germancoines
Copy link

@germancoines germancoines commented Jun 29, 2021

Description of Change

This pull request modifies the ShellSearchView class in order to actually trigger the SearchHandler OnFocused() and OnUnfocused() overridable methods as well as the Focused and Unfocused EventHandlers (disregarding if they were declared on XAML or in the CodeBehind) whenever the TextBox within the SearchHandler changes its focus state.
It also adds the Github Issues tests 7956 and 7956_1, in order to properly test such triggering of events.

The original commit that introduced the issue was e231882 . After having analised the code, my guess is that such commit intended to implement most of the features already existing within the VisualElement class by replicating parts of its code within the SearchHandler class (rather than by extending it, as many other controls do either directly or indirectly).

The mentioned commit ammended existing test cases based on the SearchHandlerPage and StorePages in order to test properties like BackgroundColor, CancelButtonColor, TextColor, PlaceholderColor, HorizontalTextAlignment, Keyboard, FontFamily, etc. but in none of them it tests that the Focused or Unfocused event handlers trigger.

Issues Resolved

API Changes

Added:

  • protected virtual void ShellSearchView.OnSearchHandlerFocusChange(object sender, FocusChangeEventArgs e);

Changed:

  • protected virtual void ShellSearchView.LoadView(SearchHandler searchHandler);

Removed:
None.

Platforms Affected

  • Android

Behavioral/Visual Changes

In case a SearchHandler (or an inheriting class) is declared within XAML providing Focused and/or Unfocused EventHandler functions, upgrading to this version will result in such events to actually trigger.

Before/After Screenshots

Before: The SearchHandler.cs Focused and/or Unfocused overridable functions nor the Focused and/or Unfocused EventHandlers (no matter if declared in XAML or CodeBehind) wouldn't trigger. Actions within the event handlers wouldn't take place (in this test, the labels contents wouldn't be shown).
image

After:

The SearchHandler.cs Focused and/or Unfocused overridable functions and the Focused and/or Unfocused EventHandlers (no matter if declared in XAML or CodeBehind) trigger. Actions within the event handlers take place (in this test, the labels contents are shown)

Issue7956.xaml - Focus
image
image
image

Issue7956.xaml - Unfocus
image
image
image

Issue7956_1.xaml - Focus
image
image
image
image

Issue7956_1.xaml - Unfocus
image
image
image
image

Testing Procedure

  1. Launch any of the Xamarin.Forms.ControlGallery.[Platform]
  2. On the main App screen, hit the 'GO TO TEST CASES'
  3. Search for the Test case 7956 and open it.
  4. A Shell view appears having a SearchHandler control on top, also a descriptive text explaining the test itself.
  5. Click (or poke) on the SearchHandler in order to cause the Focus event to trigger. A text should appear saying: Focus EventHandler triggered!
  6. Click (or poke) on any other area of the screen but the SearchHandler in order to cause the Unfocus event to trigger. A text should appear saying: Unfocus EventHandler triggered!

If steps 5 or 6 produce the mentioned output, the test would have passed. Otherwise, it would have failed.

PR Checklist

  • Targets the correct branch
  • Tests are passing (or failures are unrelated)

…Handlers triggering test. FAILS (does nothing)
@net-foundation-cla
Copy link

net-foundation-cla bot commented Jun 29, 2021

CLA assistant check
All CLA requirements met.

Germán Coines Laguna added 3 commits June 29, 2021 03:34
…sed EventHandlers triggering test. FAILS (does nothing)
…textBlock.

This is done in order to propagate any Focus state change from the textBlock (graphically, the search bar for the SearchHandler) to the SearchHandler IsFocused state.

This causes the SearchHandler.OnIsFocusedPropertyChanged method to finally execute, as it was originally expected to do so.
@germancoines germancoines marked this pull request as ready for review June 29, 2021 12:51
@germancoines germancoines changed the title #7956 SearchHandler XAML declared. Focused and Unfocused EventHandler… #7956 [Shell] Unable to focus and unfocus search handler for Android Jun 29, 2021
Copy link
Author

@germancoines germancoines left a comment

Choose a reason for hiding this comment

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

After testing the original cases as well as the new ones I've implemented, and reviewing the changes: As far as I'm concerned the impact of this PR is minimal. No breaking changes are introduced.

germancoines and others added 2 commits July 1, 2021 03:29
Co-authored-by: Pedro Jesus <pedrojesus.cefet@gmail.com>
Copy link
Author

@germancoines germancoines left a comment

Choose a reason for hiding this comment

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

Thanks @pictos !

@pictos
Copy link
Contributor

pictos commented Jul 1, 2021

@germancoines why do you implemented 7956 and 7956_1 tests? They look like the same thing. Am I missing something here? Other than that your code fixed the issue.

@PureWeen can you take a look at this one?

@germancoines
Copy link
Author

germancoines commented Jul 1, 2021

@germancoines why do you implemented 7956 and 7956_1 tests? They look like the same thing. Am I missing something here? Other than that your code fixed the issue.

@PureWeen can you take a look at this one?

Hi @pictos, @PureWeen . I just did it to check that the events (declared on XAML) were firing on both SearchHandler as well as inheriting classes . May be this wasn't needed at all, but I just wanted to double check that, as it seems to be a common use case scenario for developers.

See this comment I left on the Issue: #7956 (comment)

@germancoines
Copy link
Author

Hi @pictos @PureWeen. is there any chance to have a second reviewer for this PR and related issue?

@germancoines
Copy link
Author

Thanks @jsuarezruiz
@pictos , do you have a chance to finally approve the changes?

@pictos
Copy link
Contributor

pictos commented Oct 24, 2021

@germancoines I don't have permissions on this repo. So if Javier approved it's good to be merged (:

Thanks for your contribution ❣️

@jfversluis
Copy link
Member

Hey @germancoines thank you so much for your patience here. And @pictos thanks for helping out here as well!

If this is still of interest to you, could you confirm this is still an issue with the current stable version of Forms? I know there have been some changes in this area, and just want to confirm that this hasn't been fixed by another PR. Thanks!

@germancoines
Copy link
Author

Hey @germancoines thank you so much for your patience here. And @pictos thanks for helping out here as well!

If this is still of interest to you, could you confirm this is still an issue with the current stable version of Forms? I know there have been some changes in this area, and just want to confirm that this hasn't been fixed by another PR. Thanks!

Hi @jfversluis , I'll be checking this as soon as I can to be back with the results for your request :)

@germancoines
Copy link
Author

Hi @jfversluis, is there any update on this after my previous confirmation?

@jfversluis
Copy link
Member

@germancoines unfortunately not. So what you are basically saying is this change still needs to happen, right?

@jfversluis
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@germancoines
Copy link
Author

@germancoines unfortunately not. So what you are basically saying is this change still needs to happen, right?

Yes @jfversluis.

Not sure about the failing test results for OSX and Windows on the pipeline. Is that usual?

@germancoines
Copy link
Author

/azp run

@azure-pipelines
Copy link

Commenter does not have sufficient privileges for PR 14375 in repo xamarin/Xamarin.Forms

@germancoines
Copy link
Author

Hi @jfversluis @jsuarezruiz, I was willing to run the pipeline again in order to check the Build errors. Would it be possible to relaunch the pipeline, please?

@jfversluis
Copy link
Member

Now that we're so close to the sunsetting of Xamarin.Forms unfortunately we won't be able to take this in anymore, we're really sorry about that. Nevertheless, thank you so much for your time and effort that you have put into this PR.

Please have a look at the evolution of Xamarin.Forms, .NET MAUI. A lot of development has been going on there. Hopefully this issue was already fixed in that codebase. If not, feel free to port this over to there.

Again, thank you so much for being a contributor and Xamarin.Forms user!

@jfversluis jfversluis closed this Apr 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Shell] Unable to focus and unfocus search handler for Android
4 participants