fluentribbon / Fluent.Ribbon

WPF Ribbon control like in Office
http://fluentribbon.github.io
MIT License
2.55k stars 517 forks source link

Multiple levels of menu items of DropDownButton behaves not well #1087

Closed orrindeng closed 1 year ago

orrindeng commented 1 year ago

Hello guys,

Originally, I met an issue that clicking the menu item will close the sub menu. And later I found a bug if there are a more than two levels of sub menu. The third sub menu will show when mouse button down and close when mouse button up. image

We found we have code like this.

    protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
    {
        if (e.ClickCount == 1)
        {
            if (this.IsSplited)
            {
                if (this.GetTemplateChild("PART_ButtonBorder") is Border buttonBorder
                    && PopupService.IsMousePhysicallyOver(buttonBorder))
                {
                    this.OnClick();
                }
            }
            else if (this.HasItems)
            {
                this.IsSubmenuOpen = !this.IsSubmenuOpen;
            }
        }

        base.OnMouseLeftButtonUp(e);
    }

I looked into the dotnet WPF source code. MenuItem And found that the base WPF MenuItem will show the sub menu when mouse down. But we will close it when mouse up with this.IsSubmenuOpen = !this.IsSubmenuOpen .

orrindeng commented 1 year ago

I've created a pull request to remove this behavior. Please feel free to decline it if it's not good. Thanks.