question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`unicorn:model` clearing field when request sent

See original GitHub issue

Overview

I’m working on integrating Unicorn into a new project and want to build a form with it to remove the need for lots of JS. I’m in the very early stages of setup and I’m running into an error with unicorn:model. When typing in an input field unicorn sends a request as is intended. However, once the request is sent ( or received, I’m not too sure) the input which I have added unicorn:model="name" to the field gets emptied.

See the gif below for a demo of what’s happening. I used the example Hello World component from the docs to create the example. error demo

The request seems okay:

Payload

{
    "id":"RGxVEpbj",
    "data":{"name":"World"},
    "checksum":"GnzWzCxX",
    "actionQueue":[
        {
            "type":"syncInput",
            "payload":{"name":"name","value":"s"},
            "partials":[]
        }
    ],
    "epoch":1661435333662,
    "hash":"nRebsfnn"
}

Response

{
    "id":"RGxVEpbj",
    "data":{
        "name":"Worlds"
    },
    "errors":{},
    "calls":[],
    "checksum":"A4EcPwSS",
    "dom":"<div unicorn:checksum=\"A4EcPwSS\" unicorn:id=\"RGxVEpbj\" unicorn:key=\"\" unicorn:name=\"hello-world\">\n<input id=\"text\" type=\"text\" unicorn:model=\"name\"/><br/>\n    Hello S\n  </div>",
    "hash":"QXEkesKJ"
}

If you need any more information let me know! I’m sure this is user error rather than something wrong with the framework but I thought it worth reporting.


Edit: I just created a brand new project to test this out completely isolated and got the same result

Edit 2: It also happens when I have a forked version of this repo set up locally and use the built in examples in the local dev environment

Edit 3: This seems to be a Chrome specific bug as the code works fine in safari!

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
adamghillcommented, Aug 30, 2022

Testing on http://localhost:8080/text-inputs with the Nordpass extension is interesting to see what breaks and what doesn’t. 😂 I’m wondering if the issues might be related to morphdom which is the library I use to actual update the DOM under the hood. While I’m testing, it looks like using a key makes things work as expected.

0reactions
gschurckcommented, Sep 20, 2022

I have the same issue with Bitwarden.

While I’m testing, it looks like using a key makes things work as expected.

How did you manage to make it work @adamghill ? I don’t understand how to replace the model:search/updated_search() behavior with a key (same pattern as this example). I don’t really understand how unicorn:key work and what it does.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · adamghill/django-unicorn - GitHub
adamghill / django-unicorn Public ... model foreign key attribute getting set to None between calls ... unicorn:model clearing field when request sent.
Read more >
Actions - Django Unicorn
Discards any model updates from being saved before calling the specified method on the view. Useful for a cancel button. <!-- discard-modifier.
Read more >
UNICORN 7.0 Evaluation Manual
The Evaluation Classic module. The Evaluation module within UNICORN 7.0 contains the basic functionality needed when evaluating chromatography results.
Read more >
UNICORN 5.0 User Reference Manual
For practical reasons the user documentation is based on a model system that ... Menu commands, field names and other text items from...
Read more >
UNICORN™ 7.4 - Evaluation Manual
The manual also describes algorithms and theoretical models used in the ... This section describes the user documentation that is delivered with UNICORN....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found