0

I am using Filament 4.x with Livewire 3.x to build a tenant registration page. I have a custom loader that should display when the user clicks the register button.

The registration button is rendered dynamically via $this->content, so I cannot modify it directly.

Currently, the loader appears briefly but disappears a few seconds before the redirect occurs.

Here is my Blade template:

<x-filament-panels::page.simple> 
    {{ $this->content }}

    <div wire:loading wire:target="register">
        <div class="loader"></div>
    </div>

    @assets
        <style>
            .loader {
                font-weight: bold;
                font-family: monospace;
                font-size: 30px;
                line-height: 1.2em;
                display: grid;
                place-items: center;
                width: 100vw;
                height: 100vh;
                position: fixed;
                top: 0;
                left: 0;
                background: white;
                z-index: 9999;
            }

            .loader:before,
            .loader:after {
                content: "Setup in progress...";
                grid-area: 1/1;
                -webkit-mask: linear-gradient(90deg, #000 50%, #0000 0) 0 50%/2ch 100%;
                color: #0000;
                text-shadow: 0 0 0 #000, 0 calc(var(--s, 1)*1.2em) 0 #000;
                animation: l15 1s infinite;
            }

            .loader:after {
                -webkit-mask-position: 1ch 50%;
                --s: -1;
            }

            @keyframes l15 {
                80%, 100% {
                    text-shadow: 0 calc(var(--s, 1)*-1.2em) 0 #000, 0 0 0 #000;
                }
            }
        </style>
    @endassets
</x-filament-panels::page.simple>

Here is the register() method in the Filament tenant registration page:

public function register(): void
    {
        abort_unless(static::canView(), 404);

        try {
            $this->beginDatabaseTransaction();

            $this->callHook('beforeValidate');

            $data = $this->form->getState();

            $this->callHook('afterValidate');

            $data = $this->mutateFormDataBeforeRegister($data);

            $this->callHook('beforeRegister');

            $this->tenant = $this->handleRegistration($data);

            $this->form->model($this->tenant)->saveRelationships();

            $this->callHook('afterRegister');
        } catch (Halt $exception) {
            $exception->shouldRollbackDatabaseTransaction() ?
                $this->rollBackDatabaseTransaction() :
                $this->commitDatabaseTransaction();

            return;
        } catch (Throwable $exception) {
            $this->rollBackDatabaseTransaction();

            throw $exception;
        }

        $this->commitDatabaseTransaction();

        if ($redirectUrl = $this->getRedirectUrl()) {
            $this->redirect($redirectUrl, navigate: FilamentView::hasSpaMode($redirectUrl));
        }
    }

How can I make the loader stay visible until the redirect occurs for a Filament tenant registration action, given that the button is rendered dynamically via $this->content and cannot be modified directly?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.