scripting / Scripting-News

I'm starting to use GitHub for work on my blog. Why not? It's got good communication and collaboration tools. Why not hook it up to a blog?
121 stars 10 forks source link

Tab content does not change sometimes #288

Open fmfernandes opened 10 months ago

fmfernandes commented 10 months ago

While doing some tests for https://github.com/scripting/Scripting-News/issues/287 I came across a strange behavior which I can constantly replicate: if you switch tabs while another one is loading, the contents of the loading tab will be the same as the the first one. I recorded a couple videos demonstrating that.

Expected behavior

Tabs load as I go through them

https://github.com/scripting/a8c-FeedLand-Support/assets/24195829/e176f0f5-641a-47eb-9919-9c56931c8249

What happens

If I switch tabs fast enough, the content will be replaced and not appended to the document. In the end you can see all tabs have the same content except for the Dave tab (which I wasn't fast enough to switch before loading).

https://github.com/scripting/a8c-FeedLand-Support/assets/24195829/1db97044-9f3a-4ce8-b5c7-c07bcb179f67

scripting commented 10 months ago

@fmfernandes -- excellent report!

do you have a theory re what's happening?

fmfernandes commented 10 months ago

I haven't taken a look at the code but I guess it's some race condition.

I also noticed that the scroll bar increases in size as, and that's because the actual content of the tabs get appended to the content, it's just not showing as the first thing, so, maybe something like this:

  1. Click on a tab (tab 1), tab is active, content loads.
  2. Click on another tab (tab 2), content is loading, switch back (to tab 1).
  3. Content loading function may check which tab is active (which now is tab 1) and appends the content to that tab.
  4. You switch back to tab 2 with contents from tab 1.

I'm not sure how tied is displayRiver to tabClickCallback but that may be the issue. Another possibility is also that appending items to the DOM is taking too long that I'm able to switch tabs before it's appended.

Those are all just rough guesses 🙂