Skip to content

Back button on Update.htm #4417

Description

@Jacobnordvall

What happened?

Back button dosnt go back to index if the last page wast index. aka you clicked on git banner to get latest bin.

To Reproduce Bug

Click the git banner. then use back gesture on android. then use the back botton. It now takes you back to the git page as it tracks the last page and dosnt actually go to index page.

Expected Behavior

back goes back to last entry in the main page.

Anything else?

Here is a fully working solution for reference:

function goBackToMainPage() {
    let stepsBack = 0;
    const mainPages = ['/#Colors', '/#Effects', '/#Segments', '/#Presets'];

    function isMainPage() {
        const currentPage = window.location.href;
        return mainPages.some(page => currentPage.includes(page));
    }

    function navigateBack() {
        if (stepsBack < 60) { // Prevent infinite loop
            stepsBack++;
            window.history.back();

            setTimeout(() => {
                if (!isMainPage()) {
                    navigateBack();
                }
            }, 100); // Wait for navigation to take effect
        } else {
            // Fallback if no "main" page is found
            window.location = '/';
        }
    }

    if (!isMainPage()) {
        navigateBack();
    } else {
        // If already on a main page
        console.log("You're already on a main page!");
    }
}

and ofc the html:

<button type="button" onclick="goBackToMainPage()">Back</button>

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    externalNot part of WLED itself - an external plugin/remote etc.

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions