filament icon indicating copy to clipboard operation
filament copied to clipboard

Fix using HtmlString for HasIcon

Open pxlrbt opened this issue 1 year ago • 3 comments

Description

Tried to fix this issue on Discord: https://discord.com/channels/883083792112300104/1254017792902959124

According to the docs you should be able to pass a view to register an icon alias. This gets casted to a string though and is then outputted as an image.

Also view() doesn't work. I think the issue is that View gets converted to string when passed as a Blade component param. Not sure how to fix this. I think the issue is how we pass $icon in actions/resources/views/components/action.blade.php.

CC: @zepfietje not sure how this was intended to work. Maybe you can have a look at this.

Functional changes

  • [ ] Code style has been fixed by running the composer cs command.
  • [ ] Changes have been tested to not break existing functionality.
  • [x] Documentation is up-to-date.

pxlrbt avatar Jun 22 '24 17:06 pxlrbt

@pxlrbt

I think the issue is that View gets converted to string when passed as a Blade component param

It only happens when passing Renderables's. Htmlable's are fine. I've raised an issue with the Laravel team. It feels like a bug, but perhaps there's a good reason for it.

As discussed -- this may be a breaking change and not the solution short term.

See: https://github.com/laravel/framework/issues/51889

ju5t avatar Jun 23 '24 08:06 ju5t

Please swap it to use Htmlable and get rid of the HtmlString wrapper. If we need to do extra processing into an HtmlString internally once its passed in then we will do that, but this PR can still be updated as such for now until we have a response from Laravel.

danharrin avatar Jun 23 '24 17:06 danharrin

Is there anything I can do to help with this PR?

ju5t avatar Jun 29 '24 07:06 ju5t

I would welcome a PR to fix this, but this isn't the right way to go about it IMO. You should be able to pass in a View object as per the docs without having to wrap within an HtmlString.

danharrin avatar Jul 09 '24 09:07 danharrin