Skip to content

Unable to remove signals #1058

@human-bean-555

Description

@human-bean-555

Bug Report

Hi,

Firstly thanks for this great library - the use of signals with data-signals(_) is extremely powerful and has vastly simplified an HTMX project I have.

In migrating across I ran into an issue where I want to remove some of the current signals on the page and from reading the docs setting a signal to null I should be able do this?

My first instinct was to try setAll, however this failed. So since the docs about was removing was under the SSE events I have tried that path, but it it still doesn't work. Initially I was just trying to patch the signals with null which didn't work; then I thought because there were still other bindings in the HTML to the signal that was causing the problem; however even when removing them the signal remains.

Here is a minimal example:

Initial HTML

<div>
  <div data-signals="{ remove_me: "initial value" }" id="with-signals"></div>
  <input data-bind="remove_me" id="input-with-signal" type="text">
  <button data-on-click="@post('/remove-signal')">Try remove signal</button>
</div>

First Post to server on click

{ "remove_me": "initial value" }

Response

event: datastar-patch-elements
data: elements <input id="input-with-signal" type="text">

event: datastar-patch-elements
data: elements <div id="with-signals"></div>

event: datastar-patch-signals
data: signals {"remove_me":null}

Patched front end HTML

<div>
  <div id="with-signals"></div>
  <input id="input-with-signal" type="text">
  <button data-on-click="@post('/remove-signal')">Try remove signal</button>
</div>

Next post to the server

{ "remove_me": "" }

So the signal is still there

Datastar Version

Datastar v1.0.0-RC.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions