-
Notifications
You must be signed in to change notification settings - Fork 311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auto focus on page load #3325
Auto focus on page load #3325
Conversation
Is this the same thing @dhoehna implemented manually? Can we replace that with this? |
Amir petitioned for behaviors instead of pages. I'm okay with either approach to auto focus as long as new pages only need to do one extra thing to get auto-focus behavior. However, only one approach should be used. @AmelBawa-msft how will new pages and existing pages opt-in to using auto-focus behavior? |
@dhoehna @AmelBawa-msft Can we do both? I like how simple the behavior is / someday we could just get it from CommunityToolkit, but agree that we don't want every dev to have to add something to every page they create. Instead of putting |
An issue Amir had with my implementation is a lack of control. On the environments pages and the app pages, focus needs to be moved after the UI is loaded. If this change allows child pages to DevHome "Please load me know" cool. Otherwise, I don't agree on having two solutions solving the same auto-focus problem. I am fine with either approach, but only 1. EDIT: |
@krschau , @dhoehna, we don't have a XAML for the parent class. I vaguely remember that inheritance was non-trivial or maybe not possible when the parent class has a corresponding XAML page. Agree with Darren, I do prefer a single solution, and they both seem to be doing the same identical thing, but one from XAML and the other from code-behind. I do prefer to put things in XAML as much as possible and maintain minimal code/logic in code-behind, promoting simplicity and reusability. I will go ahead and update the other pages. @dhoehna, I don't fully recall what was your use case, but I also found FocusBehavior:
Usage: <interactivity:Interaction.Behaviors>
<behaviors:FocusBehavior>
<behaviors:FocusTarget Control="{x:Bind myTextBox}" />
<behaviors:FocusTarget Control="{x:Bind myButton}" />
</behaviors:FocusBehavior>
</interactivity:Interaction.Behaviors>
<TextBox x:Name="myTextBox" />
<Button x:Name="myButton" /> |
Shimmer and loading adaptive cards. In these cases the UI finished loading before theViewModel is done getting information. This causes the auto-focus to sometimes focus on the wrong element. |
Summary of the pull request
References and relevant issues
https://task.ms/50153184
Detailed description of the pull request / Additional comments
Validation steps performed
PR checklist