Skip to content
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

Menubar Flyout item accelerators are aligned differently when opened for the second time #8755

Closed
zkacso-dev opened this issue Aug 16, 2023 · 1 comment
Labels
bug Something isn't working team-Controls Issue for the Controls team
Milestone

Comments

@zkacso-dev
Copy link

Describe the bug

Within a MenuBar the MenuFlyoutItem control's accelerator keys are aligned to the right when you first open the flyout, but all consequent opens will align the accelerator keys to the left.

Steps to reproduce the bug

<MenuBar>
        <MenuBarItem Title="File">
            <MenuBarItem.Items>
                <MenuFlyoutItem Text="AAA">
                    <MenuFlyoutItem.KeyboardAccelerators>
                        <KeyboardAccelerator Key="A" Modifiers="Control" />
                    </MenuFlyoutItem.KeyboardAccelerators>
                </MenuFlyoutItem>
                <MenuFlyoutItem Text="BBB">
                    <MenuFlyoutItem.KeyboardAccelerators>
                        <KeyboardAccelerator Key="A" />
                    </MenuFlyoutItem.KeyboardAccelerators>
                </MenuFlyoutItem>
            </MenuBarItem.Items>
        </MenuBarItem>
    </MenuBar>

With this example code:

  1. Open the File menu (Accelerators are aligned to the right)
  2. Close the File menu
  3. Open it again (Accelerator are aligned to the left)

Expected behavior

alignment should be consistent when opening the flyout

Screenshots

First open:
image

All consequent opens:
image

NuGet package version

WinUI 3 - Windows App SDK 1.3.3: 1.3.230724000

Windows version

Windows 10 (21H2): Build 19044

Additional context

No response

@zkacso-dev zkacso-dev added the bug Something isn't working label Aug 16, 2023
@bpulliam bpulliam added the team-Controls Issue for the Controls team label Aug 22, 2023
@JJBrychell
Copy link

Interestingly, it was a bug that caused it to show correctly the first time otherwise the actual bug would have caused them to always be left aligned.

The menu aligns the accelerator values by explicitly setting the size of all the TextBlock that contains the accelerator key text to the size of the largest one, and right aligning the TextBlock. The first calculation for these widths occurs too early so the TextBlocks are just the size of their content and when they are right aligned, the appear justified to the right. However, the second (and subsequent) times that the dialog is shown it has computed the correct size of the largest Text blocks and so all the textblocks are the same size and aligned on both the right and left. BUT, the text in the text block was still being left aligned. Consequently, the accelerator strings appeared left aligned on the second (and subsequent) invocations.

The fix is in and scheduled for 1.5

@bpulliam bpulliam added this to the WinAppSDK 1.5 milestone Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working team-Controls Issue for the Controls team
Projects
None yet
Development

No branches or pull requests

3 participants