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

TextBox flyout commands and SelectableTextBox command buttons not working #590

Closed
cricketthomas opened this issue Jun 26, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@cricketthomas
Copy link
Contributor

Describe the bug

Command Flyout command buttons are not working with FA added. Nor is the SelectableTextBlock. They key bindings work as expected, its just they don't seem to work when you use the buttons on the flyouts.

It works fine in the sample app from the master branch, not sure if this is a bug or if i am just initializing something wrong.

Video of it not working:

Recording.2024-06-26.114728.mp4

Video of it working without FA installed:

Screen.Recording.2024-06-26.115114.mp4

Desktop/Platform:

  • OS: Windows 11
  • FluentAvalonia Version 2.1.0-preview6 (older previews as well)
  • Avalonia Version 11.1.0-rc1

Reproduction:
This is just a empty .NET 8 application with the latest previews install of Avalonia and FluentAvalonia.

https://github.com/cricketthomas/AvaloniaApplication2

@cricketthomas cricketthomas added the bug Something isn't working label Jun 26, 2024
@cricketthomas cricketthomas changed the title TextBox flyout commands and SelectableTextBox commands buttons not working TextBox flyout commands and SelectableTextBox command buttons not working Jun 26, 2024
@xLEGiON
Copy link
Contributor

xLEGiON commented Nov 28, 2024

As mentioned in AvaloniaUI/Avalonia#16854, PR AvaloniaUI/Avalonia#15466 sets Target to null at the end of HideCore(bool canCancel = true) in PopupFlyoutBase.cs.

FluentAvalonia's CommandBarFlyout.cs calls HideCore(false) inside OnCommandBarButtonInSecondaryCommandsClick(object sender, RoutedEventArgs e), which occurs whenever one of the buttons is clicked. I think the Click event must be firing before the command method (e.g. ExecuteCutCommand() in TextCommandBarFlyout.cs) executes. So the command method reads Target as null and doesn't do anything.

I tried commenting out HideCore(false) to test this and it made the button commands work again but left visual artifacts as it no longer gets properly hidden. I'm not familiar enough with this code to suggest the best way to fix it.

@amwx
Copy link
Owner

amwx commented Nov 29, 2024

This should now be fixed in master. To work around the issue, TextCommandBarFlyout now holds a WeakReference to the Target control when it opens so it still has access to that when it closes. I may look back at the WinUI source in the future to see if there's a better fix, but this will do for now.

@amwx amwx closed this as completed Nov 29, 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
Projects
None yet
Development

No branches or pull requests

3 participants