Skip to content
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

Issue with <PageScript> component in Blazor interactive server with prerender false #11

Open
WALEED-NET opened this issue Apr 25, 2024 · 2 comments

Comments

@WALEED-NET
Copy link

WALEED-NET commented Apr 25, 2024

Dear Mackinnon Buck ,

I hope this message finds you well. I wanted to bring to your attention an issue I encountered while using the component in Blazor interactive server with prerender set to false.

The component is designed to enable per-page JavaScript navigation callbacks in Blazor web applications, allowing for page-specific JavaScript that works seamlessly with enhanced navigation enabled or disabled. However, I noticed that when using the interactive server with prerender set to false, the component does not function correctly.

Here are the steps to reproduce the issue:

  1. Set up a Blazor web application using the interactive server template then Set Prerender to False.
  2. Create a new page (e.g., Example.razor) and define the page-specific JavaScript callbacks using the component.
  3. Make sure prerender is set to false in the server configuration.
  4. Load the page and observe that the JavaScript callbacks defined in Example.razor.js (such as onLoad, onUpdate, and onDispose) are not properly invoked.

Or you can go back to the example that you reviewed in the "ASP.NET Community Standup - Blazor Experiments + eShop Q&A"(https://www.youtube.com/live/fkDSaIti_KU?t=595&si=BsVBrvA0pS8porfk)
And Change its Render Mode Of Example to interactive server with Prerender False.

I have thoroughly tested this behavior and found that the component works as expected in other configurations, such as Blazor interactive server with prerender set to true or Blazor WebAssembly.

I believe this issue could potentially impact developers who rely on the component for page-specific JavaScript functionality in Blazor interactive server applications with prerender set to false.

I wanted to report this issue and seek your guidance on how to address it. If there are any workarounds or known solutions, I would greatly appreciate your insights. Additionally, I am willing to provide further details or assist in any further investigation required to resolve this issue.

Thank you for your attention to this matter. I look forward to your response.

Best regards,
Waleed Bensumaidea

@MackinnonBuck
Copy link
Owner

MackinnonBuck commented Sep 16, 2024

Hi @WALEED-NET, I appreciate the issue report. Apologies for the delayed reply.

Does the project you're testing with utilize top-level interactivity (not per-page)? If that's the case, the project is using interactive routing. The PageScript component is designed to work with a static router, and it uses enhanced navigation callbacks to detect when a navigation occurs. It could be adapted to support interactive routing, although I haven't prioritized this because the primary benefit of PageScript is when interactive routing/JS interop are not possible. That said, I can see the advantage of having the component work the same way regardless of the render mode configuration.

I'll use this issue to track adding support for interactive routing. It might also be worth considering calling the onUpdate method after the component renders interactively.

@WALEED-NET
Copy link
Author

Hi Mackinnon,

Thank you for your response, and no worries about the delay!

Yes, the project I'm testing does use top-level interactivity with interactive routing. I understand that the PageScript component is primarily designed for static routing, and I appreciate your insights regarding its current limitations.

As someone who is passionate about Blazor, I love diving deep into its features and solving related problems. I agree that it would be beneficial for the component to support interactive routing, especially as many applications adopt more dynamic navigation patterns. Implementing a way to call the onUpdate method after the component renders interactively could serve as a useful workaround in the meantime.

If there are any further contributions you would like me to make in the .NET community regarding Blazor, I would be more than happy to assist. Please let me know if you need any additional information from my side or if there's anything I can do to help with this issue.

Thank you once again for your attention to this matter!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants