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.

An out-of-order refresh bring old data(?)

See original GitHub issue

I have an issue with users with slow connections. They are updating invoices in their phones (android) and sometimes the values are lost or overwritten.

<input  type="text" id="discount" name="discount" inputmode="decimal" hx-post="" hx-trigger="keyup changed delay:2s" hx-swap="outerHTML" hx-target="#content" hx-select="#content">

So, this is the flow of actions:

  1. Enter a value like 23. It gets sent to the server
  2. Now remove it or change it (23.3). It gets sent to the server
  3. Sometimes it gets rewritten into 23
  4. Then the server has responded with 23 then 23.3

I attach a video of the issue: https://user-images.githubusercontent.com/238983/133696804-155505bd-600e-441d-9263-443b68b1d44c.mp4

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
mamcxcommented, Nov 3, 2021

Ok, after looking at the code and remembering I have reported this issue, I do this change:

        function handlePreservedElements(fragment) {
            forEach(findAll(fragment, '[hx-preserve], [data-hx-preserve]'), function (preservedElt) {
                var id = getAttributeValue(preservedElt, "id");
                var oldElt = getDocument().getElementById(id);
                if (oldElt != null) {
                    //preservedElt.parentNode.replaceChild(oldElt, preservedElt);
                    preservedElt.value =  oldElt.value;
                }
            });
        }

This keeps the value to be replaced and avoids “jump” out of focus. Maybe add an option to hx-preserve for values?

0reactions
mamcxcommented, Nov 3, 2021

Also keyup changed delay:1s means the delay is applied to both events? Or could be the delay is only for the last?

P.D: Removing the delay make the problem more evident.

Read more comments on GitHub >

github_iconTop Results From Across the Web

angular - Data saved in service lost on page refresh or change
toPromise() on the Http client and into the observables. It'll make working with other things (also observables) easier accross the app, and the ......
Read more >
Pivot Table Sorting Fixes & Tips - Contextures
New Excel Pivot Table Items Out of Order. When you add new records to your pivot table source data, and refresh the pivot...
Read more >
Forms response columns are out of order - Microsoft Learn
To work around this issue, locate the Responses tab on the form, click the ellipses, and then select Sync all responses to a...
Read more >
Streams Concepts | Confluent Documentation
Because the second data record would not be considered an update of the previous record. Compare this behavior of KStream to KTable below, ......
Read more >
Brute-Force Refreshing View-Data In The Background In ...
ASIDE: You might be wondering why I don't use something like the RxJS switchMap() operator so that I can cancel older requests when...
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