New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Duplicate data attributes for nested sprig() calls in template breaking requests, after 1.7.0 to 1.10.2 update #178
Comments
Thanks for reporting, this was being caused by double encoded values. Fixed in putyourlightson/craft-sprig-core@d348e41 and released in version 1.10.3. |
Thank you, we have just updated to the 1.10.3 version and the buttons are functioning again |
Ben just a quick report as it's Friday arvo here and I'm just about to head home for the weekend - but I've just had to revert back to 1.9.3 (and core 1.0.3 too...took me a moment to work that out!) - as I am seeing funky behaviour with nested components - even with version 1.10.3. I am seeing page reloads (i.e. sprig/htmx not attaching to a button) on previously working things. Pretty sure something is still not quite right here! (& Apologies for the utterly woeful bug report, will dig in next week). |
Hopefully this is enough to give you a clue, I have to run now... Parent component:
Sub component:
With 1.93 I see:
with 1.10.3 the same button is missing all the data-hx attributes:
|
The space in <button
class="btn visually-hidden sale-notes-updated-button"
id ="button-save-updated-notes-{{ tag }}" The HTML spec does allow this, however, so it is an issue with the parser that I will look into. Thanks for reporting! |
I've submitted PR craftcms/cms#9997 to fix this in Craft, although I may add the fix to Sprig directly too. |
Fixed in putyourlightson/craft-sprig-core@cf1a93d and released in version 1.10.4. |
Thanks Ben. I won't be able to try it out till Monday I'm afraid. Will let you know but I am sure you are right...surprised PHPStorm didn't ding me on that stray space!! |
Hi Ben Ok, the fix for the space works. I am still having a problem with an s-val though...athough I am not sure it's a bug as such, just a notable change in behaviour I thought worth raising. In my component I am setting an s-val (which is by default normally true), to
Previously this worked in my controller and $var['preview'] evaluated to false
However, when I inspect the sprig activated button, I see that ...and logging this in the controller I am indeed getting It's a quick fix to explicitly change to
As I say, easy to work around, but I think the way I am handling Booleans here is not uncommon, so might be worth considering? |
Thanks, fixed in putyourlightson/craft-sprig-core@23b2292 for the next release. |
Released the fix in Sprig Core 1.1.5 which you can get by running |
I have the same problem here. Child: Within Child: This leads to duplicated attributes: data-hx-headers, data-hx-post, data-hx-vals. Unfortunately, I can't figure out what the problem is. |
@rene-haefliger this issue is long closed. If the issue persists with the latest version of Sprig then please open a new issue, providing further details and code so I can replicate and test locally. |
Describe the bug
After updating to latest version of sprig from 1.7.0 to 1.10.2, elements which are marked for processing by sprig now have duplicate data-hx-* attributes causing requests to fail. This happens if the element is inside a sprig template which is called by sprig() from another sprig template.
To reproduce
Steps to reproduce the behaviour:
<button sprig s-method="post" s-action="/test">Sprig test</button>
Expected behaviour
No duplicate attributes and functioning button
Source
Versions
The text was updated successfully, but these errors were encountered: