-
Notifications
You must be signed in to change notification settings - Fork 116
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
DOM Not Updating On Blazor #54
Comments
Unfortunately, I am not familiar with Blazor. Could you explain why the solution you proposed actually fixes the problem? Does Blazor generate the DOM in a novel way or something? And it is not the ideal fix, because the existing code is meant to work with virtual DOMs, ala, Vue, React, etc. |
I'm still not 100% clear on how Blazor handles the DOM so hopefully I can explain well enough. To put it simply,
So for example, when I'm not too familiar with javascript and the DOM (and I don't use Angular, Vue, React, etc.) so maybe I'm not explaining well but regardless, it's an issue with the way Blazor handles DOM manipulation. Perhaps adding another javascript function that will force those properties to be updated would be the better solution. You keep things the same but Blazor devs still have a work around. Something as simple as: function forceUpdateDOMContent() {
halfmoon.pageWrapper = document.getElementsByClassName("page-wrapper")[0];
halfmoon.stickyAlerts = document.getElementsByClassName("sticky-alerts")[0];
} Blazor devs would just need to call this through JSInterop after render (using the Here's some documentation to get more info on Blazor. I can do some more debugging later this week when I'm working on the project again (you can see it here, just a side project). |
That's interesting. What are they set to, if not the DOM elements? In any case, I have marked this, and I would appreciate input from anyone who is more familiar with Blazor. |
This is where my knowledge of Blazor's RenderTree and lifecycle fails me. This is just my guess, but I think what may be happening is:
By adding the function in my previous comment and calling it after step 6, the element stored in Now, I may be a little off with that guess or way off. I'm not sure. The whole point of Blazor is being able to manipulate the DOM through C# and so the framework handles the DOM behind the scenes. I've never had to deal with a problem like this. |
@RoseberryPi Thank you for the details. I am not opposed to adding the method you mentioned, but I would definitely want more validation as to how Blazor actually works under the hood. |
I worked around this by calling the Halfmoon js within <body>
<app>
<component type="typeof(App)" render-mode="ServerPrerendered" />
</app>
<script type="text/javascript" src="_content/Halfmoon.Blazor/js/halfmoon.js"></script>
<script src="_framework/blazor.server.js"></script>
</body> |
@DouglasRiddle Thank you for this solution. @RoseberryPi Can you please confirm if this works for you or not? |
When I tried the code sequence like above. Drak Mode perfectly works on blazorwasm (client-side). But not the sidebar. Still digging into it. |
Just to chip in here, this is also a problem in Angular - making the change proposed by the OP fixes the issue there as well. The issue I was seeing was that toggling the sidebar was not updating the |
It is working on Blazor wasm. If it works on Blazor wasm, I believe it already works on Server-side Blazor too.
Second, in index.html inside the app tag use classes as follows.
So, the working code will look like.
|
I'm testing out Halfmoon on Blazor Server Side (an ASP.Net SPA framework) and noticed anything that relies on the
pageWrapper
andstickyAlerts
doesn't get updated correctly.To fix,
must be changed to,
in order for the sidebar to toggle (toasts and whatever else relies on those variables). Unfortunately this is just due to the way Blazor functions. I don't have time to dive deep into the issue and what Blazor is doing exactly but the elements stored in the javascript is not the one in the actual DOM.
Not sure if this is an ideal fix for you, since I don't know if it has any consequences I'm not aware of.
The text was updated successfully, but these errors were encountered: