Multiple rerendering occurs when entering data into modal html inputs
Multiple rerendering occurs when entering data into modal html inputs
Nuget package v7.1.0 - Blazor Wasm Create a component containing a simple HTML input text box Display the above component within a Blazored Modal Monitor the rerendering of the input component by logging to the console from the OnAfterRenderAsync method
Expect no rerendering of the text component on text input as no callbacks are triggered I was able to demonstrate that no rerendering occurs in v6.0.1 but that two rerenders occur in v7.1.0 for each character input into the text box
Additional context: This additional rerendering is causing issues when displaying a more complex component within the modal which itself contains child components with time delayed event callbacks (System.Reactive). The parent component rerenders causing a UI update and then rerenders again when the time delayed callback handler executes. If the modal child component itself contains an HTML input text box which invokes a delayed callback handler method on the component being displayed in the modal when a character is entered the UI behaves as follows: a) display of the new character followed by b) clearing of the new character after modal component rerender and finally c) display of the new character after the time delayed callback
Thank you for looking into this
David
Hi David,
I've just followed the steps you've provided to re-create the issue but I'm not seeing it. There are no re-renders being caused. Have you tried this in a new project or only in your existing one?
I saw this issue in my existing solution when we upgraded to .NET7 and Blazored.Modal v7.1.0. The issue goes away when we downgrade to .NET7 and Blazored.Modal v6.0.1. I have just created a new solution myself and can't reproduce the issue using the simple steps described above. I will try to identify what it is in my solution that causes the issue and post here if it is relevant to the Blazored.Modal project
Thanks for the information, David. Happy to look into this further if you identify anything.
Im going to close this issue for now as currently there isn't anything showing an issue with Modal, and I'm trying to keep things tidier in the repos. If you do find something, feel free to reopen.
Hi Chris I have investigated this issue further and have been able to reproduce the issue in a test solution (both a .NET6 and .NET7 example solution attached - also see notes in Counter.razor). The issue occurs with Blazored.Modal v7.1.0 and can be shown to disappear when downgraded to Blazored.Modal v6.0.1. Interestingly, when the Blazored.Modal v7.1.0 package is installed the issue only occurs when there is a reference type modal parameter passed into the component being displayed in the modal. When this parameter is removed the additional rendering doesn't occur. When the package is downgraded the additional rendering doesn't occur regardless of whether the reference type parameter is present. This is also the behaviour we observe in our own Blazor Wasm project.
I hope this helps. Please let me know if you need any more details. Thank you David BMIssue486.zip
Thanks for the extra work and details, David. I'll look into this further.
Could I just ask you to create a repo on GitHub with the code, downloading random zip files has bitten me once. I hope you understand.
No problem. Here is the repo: https://github.com/CCTC-team/BMIssue486 Thanks David
Good catch that it is related to reference types @phillidgithub, serializing the model is a workaround that would work until this issue is fixed.
Thanks!
I just ran into this same issue too after I upgraded to V7.1.0 and noticed I couldn't tab through the fields on my modals. On further investigation I discovered it was repeatedly calling OnSetParameters() which reset my view model, and this was occurring twice for every key stroke. As a temporary workaround I just added a boolean flag in the OnSetParameters to prevent resetting my view model after the first time it was called and works perfectly.
@as-srandall i have the same issue but idon't understand how do you solve it in OnSetParameters
I can also confirm this issue. It also occurs with blazor server projects. I encountered this while upgrading from .NET6 to 7 and switching to Blazored.Modal 7.1.0.
I am sorry if I say something stupid but would it be possible that Modal reverses the order of the events -- instead of going up, they fist going down (or there is somewhere some hard refresh). This is because I compared two cases -- I have dictionary app (Blazor WebAsm), and main page is list of words. I wanted to display Modal on top of it with the inputs, and buttons for editing.
So this is regular case. The second one, made on purpose, is that instead of displaying Modal and "editor" within it, I skipped Modal and displayed editor above the list of words.
And then I typed one letter in one of the inputs of the editor.
In the first case (with Modal) I saw a wall of setting parameters calls and those calls started at "top" level, starting from dictionary entry (as the effect whatever I type in was removed, because data flow top-down). In the second case I saw less calls, but also the calls were starting from the input and going up (so I didn't lose what I type).
Is anyone maintaining this repo anymore? There are outstanding issues that need resolving and no one seems to approve any PRs to get this repo updated? Is there any point in me fixing an issue if no one is going to approve the PR so everyone gets the benefit of the fix?
Hi @as-srandall, yes I'm still here. I appreciate things haven't move very fast with the repo this year and that it's frustrating.
I've had a lot going on in my personal life which has meant the open source stuff has had to go on the back burner. But come the new year I will be back on top of things.
Ideally, I could really do with some reliable maintainers so everything doesn't rely on myself, but they are very hard to come by.
I really do appreciate your contributions and I'll do my best to get to things in a more timely manner.
Fix via 81b78b2
Many thanks for resolving this Chris. Much appreciated as I know you are super busy right now. Cheers.