Bug in hlm-dialog with icons
Impre-visible opened this issue · comments
Please provide the environment you discovered this bug in.
import { Component } from '@angular/core';
import { lucideX, lucidePlus } from '@ng-icons/lucide';
import { NgIcon, provideIcons } from '@ng-icons/core';
import { BrnDialogComponent, BrnDialogImports } from '@spartan-ng/ui-dialog-brain';
import { HlmDialogImports } from '@spartan-ng/ui-dialog-helm';
@Component({
selector: 'app-root',
standalone: true,
imports: [NgIcon],
viewProviders: [provideIcons({ lucideX, lucidePlus })],
template: `
<hlm-dialog-content *brnDialogContent="let ctx" class="max-w-4xl">
<hlm-dialog-header>
<h3 hlmDialogTitle hlm>Icon in dialog test</h3>
</hlm-dialog-header>
<div hlmDialogOverlay class="max-w-none">
<div hlmDialogContent class="!max-w-none">
<ng-icon name="lucideX" />
<ng-icon name="lucidePlus" />
</div>
</div>
</hlm-dialog-content>
`,
})
export class App {}
Which area/package is the issue in?
dialog
Description
When you want to register/provide an icon, and display it in a hlm-dialog, it don't show up if you didn't provided it in the root AppComponent.
Please provide the exception or error you saw
"No icon named ... was found. You may need to import it using the withIcons function."
Other information
Here's the discord discussion when we found the issue: https://discord.com/channels/1145362148621557921/1304180397067731085
I would be willing to submit a PR to fix this issue
- Yes
- No
@ashley-hunter I vaguely remember you saying something like we could forward the declared icons to the root injector making them available inside the dialog. This change would be in the ng-icon package right?
My initial thoughts were that we could potentially pass the injector to the open method in the BrnDialogService:
That method accepts an injector in the config, and that would allow us to access any icons registered from wherever the dialog is launched. It should be a very easy fix, the only reason I haven't made it sooner was I wasn't actually able to reproduce the issue to verify if it is fixed or not. I guess adding this would do no harm regardless, so I could add it in and it would very likely solve the issue.