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.

Progress bar is not shown when using Turbo Frames (even with turbo-action="advance")

See original GitHub issue

Hi,

The documentation specifically mentions that the progress bar is for Turbo Drive but if you use Turbo Frames with URL history support such as when using <a href="/profile" data-turbo-frame="main" data-turbo-action="advance"> then it’s somewhat expected that the progress bar would be shown here because this page transition may happen within 50ms or 5000ms due to external network events that’s out of our control.

You can test that it’s not being shown by adding a sleep 1 between Turbo Frame page transitions and not seeing the progress bar where as if you remove the frame so that Turbo Drive picks it up then the progress bar is shown. This is with v7.1.0.

Can we make a case here to show the progress bar for all Turbo Frame events regardless of it being done with turbo-action="advance"? I’m guessing this was very thoroughly investigated at Hey / Basecamp but that discussion isn’t in the issue tracker here. Am I missing something important that would make showing the progress bar for all Turbo Frame events a bad idea?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:9
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

8reactions
dhhcommented, Feb 21, 2022

We looked at invoking the progress bar for everything, but that didn’t seem right. You can have a lot of frames triggering for lazy loading. It would be a very busy progress bar.

What I’d rather do is have an option to explicitly opt-in to using the progress bar when it’s not a full page replace. Could be as simple as data-turbo-progress-bar=true.

5reactions
onEXHoviacommented, Nov 7, 2022

👍 it would be a great addition to frames, as a temporary solution:

import * as Turbo from '@hotwired/turbo'

export default () => {
  const adapter = Turbo.navigator.delegate.adapter;
  const progressBar = adapter.progressBar;
  const session = Turbo.session;

  let progressBarTimeout = null;
  document.addEventListener('turbo:before-fetch-request', (event: Event) => {
    const target = event.target;
    if (!(target instanceof HTMLElement)) {
      return;
    }

    if ('true' === target.getAttribute('data-turbo-progress-bar')) {
      if (!progressBarTimeout) {
        progressBar.setValue(0);
      }

      progressBarTimeout = window.setTimeout(() => progressBar.show(), session.progressBarDelay);
    }
  });

  document.addEventListener('turbo:before-fetch-response', () => {
    if (progressBarTimeout) {
      window.clearTimeout(progressBarTimeout);
      progressBar.hide();
      progressBarTimeout = null;
    }
  });
};
Read more comments on GitHub >

github_iconTop Results From Across the Web

Navigate with Turbo Drive - Hotwire Turbo
During Turbo Drive navigation, the browser will not display its native progress indicator. Turbo Drive installs a CSS-based progress bar to provide feedback ......
Read more >
Rails active link styling with turbo frames - Stack Overflow
When working with frames current path not showing in browser address bar, so I've tried to force it by data-turbo-action" => "advance" ....
Read more >
Datatables From Scratch Using Hotwire (Example) - GoRails
You can using Hotwire using Turbo Frames without any custom ... method: turbo_stream.remove @project , but still the pop up doesn't show.
Read more >
Turbo Frames on Rails - Colby.so
Learning to use Turbo Frames through examples in a Ruby on Rails app. ... still find plenty of value here, but know that...
Read more >
Lazy-loading content with Turbo Frames and skeleton loader
The Turbo Frame is a super-charged iFrame that doesn't make you cringe when you use it. Frames represent a slice of your page...
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