FilamentF
Filament13mo ago
3 replies
galli.roberto

Back button

If open a create or edit page in a new tab/window, the cancel button doesn't work, because history doesn't exist.

You can try on filament-demo
https://demo.filamentphp.com/shop/customers
open a customer in a new tab/window and try to click Cancel button

The solution is really simple, add a check to history.length > 1
->alpineClickHandler(
    'document.referrer && window.history.length > 1 ? window.history.back() : (window.location.href = ' . Js::from(
        $url
    ) . ')'
)


Is it a bug?

---

SPA context

In SPA mode, when cancel button is pressed, return to the cached list page
It is a problem when a table is filtered by a discriminant field that is modified in edit, when come back to table, the cache prevent to apply right the filter.
I know that I can exclude some Resource/url from SPA, but forl all tables is annoying

At the moment I make a custom back buttom:
->alpineClickHandler(
    Filament::getCurrentPanel()->hasSpaMode() ?
        ('window.location.href = ' . Js::from($url)) :
        (
            'document.referrer && window.history.length > 1 ? window.history.back() : (window.location.href = ' . Js::from(
                $url
            ) . ')'
        )
)


Exists others options?
Was this page helpful?