Thomas
Thomas
FFilament
Created by Thomas on 6/22/2024 in #❓┊help
FilamentIcon::register view() wrongly (?) rendered as image source
As a workaround I added the Htmlable types and included this in getIcon inside the HasIcons trait:
$icon = $this->icon instanceof Renderable
? new HtmlString($this->icon->render())
: $this->icon;
$icon = $this->icon instanceof Renderable
? new HtmlString($this->icon->render())
: $this->icon;
This looks a bit weird because you're not accepting a renderable, but because a view is both this works.
54 replies
FFilament
Created by Thomas on 6/22/2024 in #❓┊help
FilamentIcon::register view() wrongly (?) rendered as image source
It never worked for two reasons. A view() is stringable. As the HasIcon trait didn't have the Htmlable type, PHP would convert it to string and render the HTML. After the type was added it didn't work either and that's because a view is also Renderable. If you pass a view to another view as a prop it renders all Renderables.
54 replies
FFilament
Created by Thomas on 6/22/2024 in #❓┊help
FilamentIcon::register view() wrongly (?) rendered as image source
That's the reason it happens. It renders Renderables. Views are renderable while Htmlable's are not.
54 replies
FFilament
Created by Thomas on 6/22/2024 in #❓┊help
FilamentIcon::register view() wrongly (?) rendered as image source
54 replies
FFilament
Created by Thomas on 6/22/2024 in #❓┊help
FilamentIcon::register view() wrongly (?) rendered as image source
At this point I want to know why this is happening. The workaround of using an html string is fine for me.
54 replies
FFilament
Created by Thomas on 6/22/2024 in #❓┊help
FilamentIcon::register view() wrongly (?) rendered as image source
In sanitizeComponentAttribute I've added a conditional for Htmlable, that doesn't sanitize the view, but further down the line it's still rendered somehow
54 replies
FFilament
Created by Thomas on 6/22/2024 in #❓┊help
FilamentIcon::register view() wrongly (?) rendered as image source
Hm, no, that's not it. It's still returned as a string somehow 🤦‍♂️
54 replies
FFilament
Created by Thomas on 6/22/2024 in #❓┊help
FilamentIcon::register view() wrongly (?) rendered as image source
I'll add it to the PR
54 replies
FFilament
Created by Thomas on 6/22/2024 in #❓┊help
FilamentIcon::register view() wrongly (?) rendered as image source
That's the reason it gets converted. A view has __toString() and HtmlString doesn't.
54 replies
FFilament
Created by Thomas on 6/22/2024 in #❓┊help
FilamentIcon::register view() wrongly (?) rendered as image source
54 replies
FFilament
Created by Thomas on 6/22/2024 in #❓┊help
FilamentIcon::register view() wrongly (?) rendered as image source
I've done some digging but I think that's unrelated. It seems like passing an Htmlable as a prop to a component renders it. When you use an HtmlString it works. Feels like a bug in Laravel but I can't find how that works.
54 replies
FFilament
Created by Thomas on 6/22/2024 in #❓┊help
FilamentIcon::register view() wrongly (?) rendered as image source
54 replies
FFilament
Created by Thomas on 6/22/2024 in #❓┊help
FilamentIcon::register view() wrongly (?) rendered as image source
Huh, maybe I'm not checking the right file but it's checking for Htmlable
54 replies
FFilament
Created by Thomas on 6/22/2024 in #❓┊help
FilamentIcon::register view() wrongly (?) rendered as image source
That doesn't matter, Laravel checks if it's an Htmlable element and calls toHtml(), if you check Laravel's source it never checks if something is an HtmlString, it always checks if its Htmlable
54 replies
FFilament
Created by Thomas on 6/22/2024 in #❓┊help
FilamentIcon::register view() wrongly (?) rendered as image source
As HtmlString implements Htmlable
54 replies
FFilament
Created by Thomas on 6/22/2024 in #❓┊help
FilamentIcon::register view() wrongly (?) rendered as image source
HtmlString is just a wrapper to create an Htmlable from a string though?
54 replies
FFilament
Created by Thomas on 6/22/2024 in #❓┊help
FilamentIcon::register view() wrongly (?) rendered as image source
Maybe it gets converted at some point because a view does return an Htmlable element
54 replies
FFilament
Created by Thomas on 6/22/2024 in #❓┊help
FilamentIcon::register view() wrongly (?) rendered as image source
I've only tested it in HasIcon's icon() method for now.
54 replies
FFilament
Created by Thomas on 6/22/2024 in #❓┊help
FilamentIcon::register view() wrongly (?) rendered as image source
It should once Htmlable is added to all the methods
54 replies
FFilament
Created by Thomas on 6/22/2024 in #❓┊help
FilamentIcon::register view() wrongly (?) rendered as image source
Never knew that, interesting
54 replies