-
-
Notifications
You must be signed in to change notification settings - Fork 533
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
[Bug]: ModalProvider loses parameter reference when closing popup #5288
Comments
Indeed, currently the ModalProvider does not keep state very well. As when it needs to re-render modals it does not reuse the RenderFragment. There's this related issue, where we want to make it so it's aware of the RenderMode that is set and manages state accordingly : #4612 |
@David-Moreira This has been open for exactly one year. Are you going to fix this now or leave it for later? because if it's not going to be fixed now, I need to find an alternative solution. |
or if you have any workarounds, that works for me too. |
I'm not sure we should change the behaviour in middle of v1.4. Users might depend on how it behaves already, even if one could assume it should not behave like it does. I'd do #4612 for v1.5 which should solve your problem in needing to keep state. @stsrki thoughts? Well in the meantime, for workaround... maybe you could keep the state in localStorage or something like that, and make sure that the Other than that, the usage of regular Modals. But this can be a little more cumbersome depending on your needs. I'll update you if I think of any more ideas. |
I'd do it in 1.5. It's not so far until release. |
ok. i will wait |
@drma-tech @stsrki can we revive nightly builds #5143 and have @drma-tech test the feature ahead of the release if he would be available to when we merge the feature in. |
We can try to make it on MyGet. |
@drma-tech this issue should be fixed with the introduction of #5304 If you'd like to test the feature ahead of time and give us feedback, please use our dev packages for v1.5.0. |
I still haven't been able to understand what I have to change in the code to maintain the popup state. I also didn't see anything in the documentation (is it a different domain?). Do you have any code examples I can use? You can also change the project I submitted here. |
At the moment we do not have documentation live for dev / pre-releases. Documentation/Blazorise.Docs/Pages/Docs/Services/ModalProvider/Examples/ModalProviderStatefulExample.razor https://github.com/Megabit/Blazorise/blob/master/Documentation/Blazorise.Docs/Pages/Docs/Services/ModalProvider/ModalProviderPage.razor |
Well, in addition to not solving the problem, the close of the first popup stops working. From what I understand, this stateful maintains the popup reference for future uses, but this has no relation to the problem I reported. The problem is not opening the popup, but closing the popup. When I close the second popup, the reference to the first is lost, and enabling stateful doesn't change this at all. Maybe what can solve this is the ElementId, but from what I understand it is only used in Show() and not in Hide(). Is there something I don't understand or is that it? I uploaded updates to the project so you can check. |
Hello @drma-tech |
Hello @drma-tech It seems like you are binding an object reference as the This should work and be a decent workaround for now? As for the issue itself, I do believe you have a point, but we're just using regular blazor RenderTreeBuilder api internally, |
Why first popup is refreshing if I'm interacting only with the second one? Note: change only a property, doesn't work for me, cause I need the whole object . |
Is the component or the blazor that generates this refresh? If it's from the component, just avoid calling refresh, if I'm not interacting with the popup. If it's Blazor, you can keep these parameters in memory and pass them via callback or any other way. |
You would just be avoiding the issue if that's the case.
well that's how it's supposed to work... The reference is captured. Blazor recommends using the approach of EventCallbsck to notify parameter changes back to the consumer of the component, instead of mutating the value directly. (here the consumer would be the page that called the first pop-up) If you are that sure it's an easy fix, You are free to help us solve the issue by coming up with a PR if you'd like. We'd really appreciate it. :) Cheers. |
I was spending a little more time over this, I believe I found out the issue with both your approach and Blazorise. In your approach if you want to make sure the reference is correctly updated, you will need to provide something like a
Don't bother reading next section, if you don't care about our technical details, As for our side, I believe we should capture & re-evaluate the Currently we use it once, the time you click I made some successful attempts with something along these lines @stsrki any concerns? I'd patch this in v1.4 if I don't identify any issues. |
I had tried this strategy of updating the original reference, but as it wasn't working, I imagined that you cut the binding and it was something internal to the popup, so I didn't know what to do to resolve it. If you cut the binding, would it solve the problem? Like, what was passed to the popup will not be affected by anything external, unless it is intentional. |
To resolve it as a temporary workaround I see two options:
Can you rephrase this? I'm not sure what you mean. We are thinking in re-evaluating the parambuilder you pass on to the ModalService which should be closer to how Blazor works in components. i.e We expect that |
i already try to do that, but i couldnt figure out who is calling this change to be able to fix that
It's a crazy idea, I don't know if it will work. You said that changing Show() and forcing the original reference to update would correct this problem, so it means that the popup would have an active binding and would accept future changes. If, at the time of Show(), you take these parameters and duplicate this reference (with a shadow copy or something similar), the binding would be inactive and would not suffer external interference. |
I updated to dev2. I made the changes you suggested, but it still doesn't work. Have you tested these changes? I have already updated the project. |
Hello. |
Oh, but you are right in assuming the change would also be in master. @stsrki have you merged in 1.4 patch to master yet, you usually do it on release day right? |
Yes, it's already merged into 1.4. But, I cam always unmerge it if you think it is worth it. |
Ah? I'm asking whether have you merged it to master yet. Since drma was trying to test it through our master dev release. |
Ah, sorry, I misunderstand. I will merge it now and run the pipeline. |
It is now released as 1.5.0-dev-3. |
ok, now its working. :) |
Blazorise Version
all
What Blazorise provider are you running on?
Bootstrap4
Link to minimal reproduction, or a simple code snippet
https://github.com/drma-tech/LostReferencePopup/tree/master/LostReferencePopup
Steps to reproduce
https://www.awesomescreenshot.com/video/24634047?key=6e7dea7043e561daaea2891e9c94e7fd
What is expected?
the value/reference should only be changed intentionally
What is actually happening?
When the popup is opened by the service (this does not happen with the embedded popup) the parameters that were loaded in this call are reset when the popup closes.
What browsers are you seeing the problem on?
Chrome
Any additional comments?
No response
The text was updated successfully, but these errors were encountered: