Skip to content
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

Signals cleared when datastar-merge-fragments overwrites existing fragment with signals #588

Open
td0m opened this issue Feb 3, 2025 · 2 comments · May be fixed by #608
Open

Signals cleared when datastar-merge-fragments overwrites existing fragment with signals #588

td0m opened this issue Feb 3, 2025 · 2 comments · May be fixed by #608
Assignees
Labels
bug Something isn't working

Comments

@td0m
Copy link
Contributor

td0m commented Feb 3, 2025

take this example:

<div
  id="fragment"
  data-signals-foo="'bar'"
>
  <div data-text="$foo"></div>
  <button data-on-click="@get('/fragment')">reload</button>
</div>

GET /fragment merges the same fragment using datastar-merge-fragments.

Expected

Pressing reload to just do nothing (since merged fragment sent back is exactly the same).

Actual

Unfortunately instead the signals get cleared (foo is set to empty string and div disappears).

@bencroker bencroker added the bug Something isn't working label Feb 3, 2025
@bencroker bencroker self-assigned this Feb 3, 2025
@td0m
Copy link
Contributor Author

td0m commented Feb 3, 2025

To add to this report - this happens when using the default mergeMode of morph. If anyone is having the same issue - you can use mergeMode inner as a temporary fix. But note this won't merge any signals updated from data-signals in the root attributes.

@bencroker bencroker linked a pull request Feb 4, 2025 that will close this issue
@bencroker
Copy link
Collaborator

Thanks for the report! This is actively being worked on in #608.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants