ux icon indicating copy to clipboard operation
ux copied to clipboard

[Turbo] `data-turbo-track` attribute for CSS is missing

Open seb-jean opened this issue 1 year ago • 6 comments

Hi :),

I see that the JS links have the data-turbo-track attribute but not the CSS ones: https://github.com/symfony/ux/blob/2.x/src/Turbo/src/DependencyInjection/TurboExtension.php#L102

https://turbo.hotwired.dev/reference/attributes

seb-jean avatar Sep 08 '24 20:09 seb-jean

I see that the JS links have the data-turbo-track attribute but not the CSS ones:

Not "the JS links", only the importmap script, if AssetMapper is installed :)

Are you suggesting a new feature ? Or is there something not working as you'd expect ?

smnandre avatar Sep 08 '24 20:09 smnandre

For https://ux.symfony.com/ there is the following source code:

Capture d'écran 2024-09-08 224749

Shouldn't that be it?

[...]
<link rel="stylesheet" href="/assets/styles/app-e6e5573999adb63729abd6652c7ebcd5.css" data-turbo-track="reload">
<link rel="stylesheet" href="/assets/vendor/tippy.js/dist/tippy-2cffb277c396057474574f721014a03f.css" data-turbo-track="reload">
<link rel="stylesheet" href="/assets/vendor/tippy.js/themes/translucent-02f3023fa2e1a35311c7e80893e98a69.css" data-turbo-track="reload">
<script type="importmap" data-turbo-track="reload">
[...]

seb-jean avatar Sep 08 '24 20:09 seb-jean

Can you explain why?

I do not agree nor disagree here, it's a genuine question :)

Is it always the case ? Or something developper should set manually ?

It seems logical to me on the importmap, but i feel (i may be wrong) that stylesheet rule would be really hard to generalize

Could you illustrate on the website what would be the effect / in which scénario ? :)

smnandre avatar Sep 08 '24 22:09 smnandre

These are genuine questions :)

smnandre avatar Sep 10 '24 21:09 smnandre

I don't have an example to give you :/. I saw it used on https://app.hey.com/.

seb-jean avatar Sep 12 '24 07:09 seb-jean

Well, i don't think we can do it with AssetMapper / ImportMap for now.... at least not with the importmap() function.

https://github.com/symfony/symfony/blob/44395abfcb2c859b26e0c6880c74dadd94da1038/src/Symfony/Component/AssetMapper/ImportMap/ImportMapRenderer.php#L140-L144

        foreach ($modulePreloads as $url) {
            $url = $this->escapeAttributeValue($url);

            $output .= "\n<link rel=\"modulepreload\" href=\"$url\">";
        }

But this could be a good PR for AssetMapper :)

smnandre avatar Sep 12 '24 11:09 smnandre

Thank you for this issue. There has not been a lot of activity here for a while. Has this been resolved?

carsonbot avatar Mar 13 '25 12:03 carsonbot

Could I get a reply or should I close this?

carsonbot avatar Mar 27 '25 12:03 carsonbot

Hey,

I didn't hear anything so I'm going to close it. Feel free to comment if this is still relevant, I can always reopen!

carsonbot avatar Apr 10 '25 12:04 carsonbot