-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[WinUI] First Entry/Editor gets focus if put inside ScrollView #11472
Comments
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
It looks like this is a WinUI issue |
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
We could potentially work around this by doing something like this? https://stackoverflow.com/questions/49713033/uwp-scrollviewer-unexpected-behavior Maybe we can change the default style yo have this ContentControl in the actual control... Not sure how that would work. |
Verified this on Visual Studio Enterprise 17.7.0 Preview 1.0. This issue does not repro on Android 13.0-API33, repro on Windows 11 with sample Project: FocusSpike.zip |
I've found a pretty clean workaround using a handler mapping:
|
@Felicity-R Is there any known issue with the workaround, please? I mean does it break something? |
Nothing I've come across. I suppose it would impact tab keyboard navigation since it's making the container a tab stop, so if keyboard navigation is important in your app you should test to see if that change is a problem for you. |
Very simple very easy fix that works. found this https://stackoverflow.com/questions/42231163/is-it-possible-to-stop-the-first-entry-getting-focus-in-a-scrollview-in-xamarin and mentions
|
It seems this issue is related to the WinUI3. You can take a look at WinUI 3 Gallery App to see this behavior. All the panels are focusable and deliver focus logic to their children recursively. When you click a container, it automatically delivers focus to the first nearest focusable child such as TextBox like in this case. If you disable focusing for the parent panel ( #if WINDOWS
stackLayout.HandlerChanged+= (s,e)=>
{
if (stackLayout.Handler.PlatformView is Microsoft.Maui.Platform.LayoutPanel panel)
{
panel.AllowFocusOnInteraction = false;
panel.GettingFocus += (s, e) =>
{
e.Cancel = true;
};
}
};
#endif |
The issue was closed as fixed in WinAppSDK 1.6 three weeks ago. However, WinAppSDK 1.6 is expected to be released 6 months after 1.5 which was released 3 weeks ago. So there should be a fix in ~5 months. |
Should be fixed by #24266. |
Description
On WinUI platform, if Entry or Editor are put inside a ScrollView, they do not lose focus correctly on click on empty space or other non-focusable elements. Instead, the first Entry or Editor is focused.
This same bug was earlier present in Xamarin.Forms (and is still open):
xamarin/Xamarin.Forms#10420
Steps to Reproduce
Link to public reproduction project repository
https://github.com/maiia-kuzmishyna/MAUI-EntryScrollViewFocus
Version with bug
6.0.400
Last version that worked well
Unknown/Other
Affected platforms
Windows
Affected platform versions
Windows 11 (SDK 10.0.19041.0)
Did you find any workaround?
I didn't find any universal workaround, however focus is lost properly on click on Button / other focusable controls.
Relevant log output
No response
Depends on
The text was updated successfully, but these errors were encountered: