Microsoft-ui-xaml: Single enter key does not trigger NavigationView's ItemInvoked event

Created on 4 Sep 2020  ·  7Comments  ·  Source: microsoft/microsoft-ui-xaml

Describe the bug
When using the keyboard to select items in a navigation view, a single enter won't work. For it to work, the user needs to hit the enter key twice so that the navigation view item gets selected. This is very glitchy, since it works sometimes, and sometimes it doesn't.

Related internal issue

Steps to reproduce the bug
Notice how the "Enter" key is entered twice:

double-enter-Trim-2

Expected behavior
it should work in one single "Enter" key.
This works okay with navigation items that don't recalculate focus:
working

Version Info
2.4.2


Windows app type:
| UWP | Win32 |
| :--------------- | :--------------- |
| | |


| Windows 10 version | Saw the problem? |
| :--------------------------------- | :-------------------- |
| Insider Build (xxxxx) | |
| May 2020 Update (19041) | Yes |
| November 2019 Update (18363) | |
| May 2019 Update (18362) | |
| October 2018 Update (17763) | |
| April 2018 Update (17134) | |
| Fall Creators Update (16299) | |
| Creators Update (15063) | |


| Device form factor | Saw the problem? |
| :----------------- | :--------------- |
| Desktop | Yes |
| Xbox | |
| Surface Hub | |
| IoT | |

Additional context

area-NavigationView team-Controls

Most helpful comment

I'm afraid beside listening to the KeyDown event yourself, there isn't much you can do. I think the issue that caused this was faulty logic to determine whether we are in a "repeated keypress" state, which was refactored later and fixed. If you are using a template for all of your NavigationViewItems, the best would be to listen on those for the KeyDown event. In the case of NavigationViewItems defined through markup, I would still say that that is the best solution, though you would need to listen to the KeyDown event of multiple items which of course is more work. But in the end unfortunately, I don't think you will be able to work around this without listening to KeyDown.

All 7 comments

I can't seem to repro this with the latest commits of the XAML Controls Gallery. The store version shows this behavior, but given that the store version is probably not using the latest WinUI bits. Given that this behavior also doesn't repro in the MUXControlsTestApp, this was probably already fixed.

@chingucoding I noticed this. Is there any workaround we can use? We are stuck with 2.4.2 for now and can't move over to 2.5 yet. I guess we could listen to the MainPage.xaml's KeyDown event and try to raise the event manually, but would feel super hacky.

I'm afraid beside listening to the KeyDown event yourself, there isn't much you can do. I think the issue that caused this was faulty logic to determine whether we are in a "repeated keypress" state, which was refactored later and fixed. If you are using a template for all of your NavigationViewItems, the best would be to listen on those for the KeyDown event. In the case of NavigationViewItems defined through markup, I would still say that that is the best solution, though you would need to listen to the KeyDown event of multiple items which of course is more work. But in the end unfortunately, I don't think you will be able to work around this without listening to KeyDown.

Closing this issue given that this is not repro'ing in mux controls test app and the issue seems fixed.

@ranjeshj hey do you know when there will be a new release of xaml controls gallery?

@ranjeshj hey do you know when there will be a new release of xaml controls gallery?

That would be a question for @stmoy.

The next release is likely to align with WinUI 2.5 unless there is a pressing need to release another version earlier than that.

Was this page helpful?
0 / 5 - 0 ratings