awcodes / scribble

MIT License
42 stars 6 forks source link

[Bug]: requiresConfirmation modal not opening form modal block #28

Closed monteduro closed 3 months ago

monteduro commented 3 months ago

What happened?

If I create a block with a modal and within the block, I add a confirm button (or any other script to open a modal), nothing happens. There are no JavaScript errors or anything else; simply nothing happens.

I suppose it's because the modal component of Filament is not being used, because with the Tip-Tap editor of Filament, it was perfectly possible to open a modal from an already open modal for the insertion of a block.

How to reproduce the bug

To reproduce, all that is needed is to add a button with requiresConfirmation to the NoticeForm that is provided in the documentation (I report the code below).

When the form is opened and the button is clicked, nothing happens, whereas a confirmation modal should appear.

<?php
namespace Awcodes\Scribble\Modals;

use Awcodes\Scribble\Enums\SlideDirection;
use Awcodes\Scribble\Livewire\ScribbleModal;
use Awcodes\Scribble\Profiles\MinimalProfile;
use Awcodes\Scribble\ScribbleEditor;
use Filament\Forms\Components\Actions;
use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Components\Radio;

class NoticeForm extends ScribbleModal
{
    public ?string $header = 'Notice';

    public static ?SlideDirection $slideDirection = SlideDirection::Right;

    // this should match the identifier in the tool class
    public ?string $identifier = 'notice';

    public function mount(): void
    {
        $this->form->fill([
            'color' => $this->data['color'] ?? 'info',
            'body' => $this->data['body'] ?? null,
        ]);
    }

    public function getFormFields(): array
    {
        return [
            Radio::make('color')
                ->inline()
                ->inlineLabel(false)
                ->options([
                    'info' => 'Info',
                    'success' => 'Success',
                    'warning' => 'Warning',
                    'danger' => 'Danger',
                ]),
            ScribbleEditor::make('body')
                ->profile(MinimalProfile::class)
                ->columnSpanFull(),
            Actions::make([
                Action::make('resetStars')
                    ->icon('heroicon-m-x-mark')
                    ->color('danger')
                    ->requiresConfirmation()
                    ->action(function(){
                      \Log::info('test');
                    })
            ])

        ];
    }
}

Screenshot 2024-04-10 alle 15 34 47

Package Version

0.3.7-alpha

PHP Version

8.2.15

Laravel Version

10.48.4

Which operating systems does with happen with?

No response

Notes

No response