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

CssEvents TransitionEventService tries to dynamically inject transitionEvents.min.js with relative path which produces invalid links #124

Open
umahanov opened this issue Mar 2, 2023 · 0 comments

Comments

@umahanov
Copy link

umahanov commented Mar 2, 2023

I have a blazor server app.

When I try to use Modal dialog component, which requires CssEvents component on my pages TransitionEventService produces transitionEvents.min.js with invalid path.

Microsoft.JSInterop.JSException: Failed to fetch dynamically imported module: http://localhost:5258/#registration-form_content/Majorsoft.Blazor.Components.CssEvents/transitionEvents.min.js

This happens because TransitionEventService tries to inject it with relative path and not absolute.

private async Task CheckJsObjectAsync()
    {
      if (this._transitionJs != null)
        return;
      this._transitionJs = await this._jsRuntime.InvokeAsync<IJSObjectReference>("import", (object) "./_content/Majorsoft.Blazor.Components.CssEvents/transitionEvents.min.js");
    }

To solve this issue I created my own TransitionEventService and couple of internal classes to simply inject NavigationManager in it

    private async Task CheckJsObjectAsync()
    {
      if (this._transitionJs != null)
        return;
      this._transitionJs = await this._jsRuntime.InvokeAsync<IJSObjectReference>("import", (object) _navigationManager.ToAbsoluteUri("./_content/Majorsoft.Blazor.Components.CssEvents/transitionEvents.min.js"));
    }

The problem is that I need to recreate each service file for each js and css services. It is easier to write my own component.
Can you please fix it or maybe you have a better solution for that

It seems to work, but I am not sure this is the best way to do it.

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

1 participant