Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

progressBarDelay not working when Back press #1058

Open
gengamer opened this issue Nov 2, 2023 · 3 comments
Open

progressBarDelay not working when Back press #1058

gengamer opened this issue Nov 2, 2023 · 3 comments

Comments

@gengamer
Copy link

gengamer commented Nov 2, 2023

I set progress bar delay to 2000 by changing this.progressBarDelay(500 to 2000). Turbo cache control no cache. It works when visiting new pages by clicking links or forms. But if back button pressed, Progress bar immediately showing instead of 2000 delay. Additionally, tried Turbo.setProgressBarDelay(2000); but not working on back press.

@gengamer gengamer closed this as completed Nov 7, 2023
@jaredcwhite
Copy link

I'm seeing this same issue as well. Why was this closed? @risinginsider Did you find a workaround?

@gengamer
Copy link
Author

gengamer commented Nov 19, 2023

@jaredcwhite I am using nprogress to get full control over the progress bar. https://github.com/rstacruz/nprogress/

@zavarock
Copy link

Workaround in case someone is interested:

let turboPopstateProgressBarTimeoutId;

window.addEventListener('popstate', (event) => {
    if (event.state.turbo) {
        Turbo.session.adapter.progressBar.progressElement.hidden = true;

        if (turboPopstateProgressBarTimeoutId) {
            clearTimeout(turboPopstateProgressBarTimeoutId);
        }

        turboPopstateProgressBarTimeoutId = setTimeout(() => {
            Turbo.session.adapter.progressBar.progressElement.hidden = false;
        }, Turbo.session.progressBarDelay);
    }
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants