Open V1ck3s opened 6 months ago
@henon I haven't debugged it, but in my theory the problem is in the IActivatable
architecture.
The MudBaseButton
is triggering this:
https://github.com/MudBlazor/MudBlazor/blob/5b3757a4c881e4b69b4f8eead488e22c1280d905/src/MudBlazor/Base/MudBaseButton.cs#L135
and then it propagates to MudMenu
:
https://github.com/MudBlazor/MudBlazor/blob/5b3757a4c881e4b69b4f8eead488e22c1280d905/src/MudBlazor/Components/Menu/MudMenu.razor.cs#L347-L350
But the problem is that the MudMenu
doesn't know anything about the AutoClose
setting in MudMenuItem
that triggered it (technically speaking, it's not even MudMenuItem
that triggered it but the Button that is under it) and honestly I don't know how we can we make this info flow.
I only have in mind a workaround for MudBaseButton
with additional property that won't call the IActivatable.Activate
but doesn't sound optimal.
I think I had the same problem in #7213.
preventDefault
as well 🤔I think I had the same problem in #7213.
It could be, because the next and previous buttons are mud buttons which is invoking the Activateable
, but when you click in the middle (year) then it doesn't close because it's just a native button
.
8331 is related but doesn't fix it the way it is. Maybe MudButton needs
preventDefault
as well 🤔
I don't think that the core problem is same, but that's just my theory.
@ScarletKuro You were right! It is indeed the IActivatable
framework causing this. There is a workaround. You can create a containter component that implements IActivatable
and put the buttons inside of it. Here is the fixed menu: https://try.mudblazor.com/snippet/wYQSanFmRxwqjzLD
As long as we don't have a good strategy to fix this I'd say we won't fix.
My only idea would be to add some ActivatableContext
that flows with the CascadingValue
, MudMenuItem
is modifying it with the AutoClose
settings, and mudbutton just forwards the new ActivatableContext
. But that would require the interface to change.
My only idea would be to add some
ActivatableContext
that flows with theCascadingValue
,MudMenuItem
is modifying it with theAutoClose
settings, and mudbutton just forwards the newActivatableContext
. But that would require the interface to change.
@ScarletKuro Can we make that interface change in v7?
I don't think that is something we should work on in v7. It is a fringe problem and has a good workaround besides.
@henon @ScarletKuro Just so I understand, why do we have to toggle the menu when Activate
is called?
Without ToggleMenu
:
https://github.com/MudBlazor/MudBlazor/assets/7112040/88cdd07f-2990-40af-a6b5-780d8ed30ead
@danielchalmers I don't understand what you are suggesting. You suggest to remove a line of code from MudMenu that was put there for a reason?
@danielchalmers I don't understand what you are suggesting. You suggest to remove a line of code from MudMenu that was put there for a reason?
@henon No, I'm asking what that reason is.
Oh, ok. The IActivatable interface was invented to allow custom action content with buttons. We'd define render fragments the users could fill with their own content and be sure the button would activate the componet. This was conceived especially for things like Close buttons. In the case of Menu, it implements this interface so that you can add a Close-button to it when it doesn't have its own special close button, which would be a nightmare to support out of the box with placing, styling and all. I hope my somewhat incoherent explanation makes sense.
Bug type
Component
Component name
MudMenuItem
What happened?
When we use a button (of any type) in a MudMenuItem, when we click on it, it does not respect the AutoClose property. On this GIF, all MudMenuItem has AutoClose at false.
Expected behavior
The menu should not close.
Reproduction link
https://try.mudblazor.com/snippet/cOcIknYpniQimiZP
Reproduction steps
Relevant log output
No response
Version (bug)
6.16.0
Version (working)
No response
What browsers are you seeing the problem on?
Firefox, Chrome, Microsoft Edge
On what operating system are you experiencing the issue?
Windows
Pull Request
Code of Conduct