jsakamoto / Toolbelt.Blazor.LoadingBar

Loading bar UI for Client-Side Blazor application.
Mozilla Public License 2.0
172 stars 18 forks source link

Script selector does not work when you set a base path #20

Closed pablopioli closed 3 years ago

pablopioli commented 3 years ago

I know this is an edge case, but when you have a Blazor app that doesn't run in the root of the site an error is thrown.

When you use a base path you can end with an script tag as

<script src="/app/_framework/blazor.webassembly.js"></script>

In this case the selector UseLoadingBar cannot find the script tag and the app fails at start.

As ScriptInjectorComponent is internal an option to configure this tag could be necessary in this cases. I could write the pull request if this solution is acceptable.

Thanks for this great component.

jsakamoto commented 3 years ago

Thank you for reporting!

I could write the pull request if this solution is acceptable.

Thanks! However, adding a new configuration option for this purpose will be very hard, I think. Because the UseLOadingBar() extension method runs before configured the DI container.

So, I came up with the idea that the query selector which specifies the injection point should be changed to <script[src]>.

https://github.com/jsakamoto/Toolbelt.Blazor.LoadingBar/blob/5ea43d47418a2d62f9bb3bf8c7a1a1340b19b5bc/Toolbelt.Blazor.LoadingBar/LoadingBarExtension.cs#L69

I will apply this idea and publish a new version of this package in a few days.

jsakamoto commented 3 years ago

I rolled out the fixed version v.13.1.1 just now.

Please try it out. 🙂

pablopioli commented 3 years ago

I can confirm that version 13.1.1 resolves this problem.

Thanks!