SamProf / MatBlazor

Material Design components for Blazor and Razor Components
http://www.matblazor.com
MIT License
2.84k stars 386 forks source link

MatMenu inside loop #163

Open novfal opened 5 years ago

novfal commented 5 years ago

MatMenu carrying last instance for all the listitems in foreach loop

SamProf commented 5 years ago

Potentially you need to save to temp variable in foreach.

https://blazorfiddle.com/s/czzvzdqb

novfal commented 5 years ago

we want MatMenu inside the foreach loop @SamProf

@foreach (var subtask in subtasks) { }
Chek
@{ @subtask.SubTaskName }
ctrl-alt-d commented 5 years ago

Answered on StackOverflow

salanford commented 4 years ago

Unfortunately this StackOverflow solution doesn't seem to work correctly. If you refresh the underlying data the MatMenu references are not recreated for some reason. Any workaround for this?

Example BlazorFiddle

henon commented 4 years ago

@salanford: I would say you should put the button and its menu into its own component. and use that in a foreach loop. I suspect this is not a MatBlazor bug. Not sure if it is a Blazor bug or not. If you can recreate this behavior without MatBlazor components I'd suggest to raise an issue directly at the Blazer repo.