kenepa / banner

Filament banner allows you to easily create, manage, and display banners in your application.
MIT License
57 stars 7 forks source link

[Bug]: Problem with resource delete button on edit page #10

Closed ap1969 closed 5 days ago

ap1969 commented 2 months ago

What happened?

Hi, if I install/enable the plugin, the delete button a standard Filament resource page takes 2 clicks to work:

  1. The first click does something - the main edit form shifts up slightly, but that's it. No confirmation box (if the DeleteAction includes it), and it doesn't delete.
  2. The second click then does the normal delete action including confirmation etc.

How to reproduce the bug

Package Version

0.0.5

PHP Version

8.2.14

Laravel Version

10.48.16

Which operating systems does with happen with?

Linux

Notes

Source code for the resource:


<?php

namespace Notifium\FilamentMarketingreminder\Filament\Resources;

use App\Scopes\TenantDataScope;
use Filament\Forms\Components\TextInput;
use Filament\Tables\Columns\CheckboxColumn;
use Filament\Tables\Columns\TextColumn;
use Notifium\FilamentMarketingreminder\Filament\Resources\ScheduleResource\Pages;
use Notifium\FilamentMarketingreminder\Filament\Resources\ScheduleResource\RelationManagers;
use Notifium\FilamentMarketingreminder\Models\Schedule;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;

class ScheduleResource extends Resource
{
    protected static ?string $model = Schedule::class;

    protected static ?string $navigationIcon = 'heroicon-o-calendar-days';

    protected static ?string $navigationGroup = 'Reminders Admin';
    protected static ?int $navigationSort = 2;

    public static function shouldRegisterNavigation() : bool
    {
        return auth()->user()->isSuperAdmin();
    }

    public static function form(Form $form) : Form
    {
        return $form
            ->schema([
                TextInput::make('name'),
                TextInput::make('key'),
                Forms\Components\Checkbox::make('onetime')->label("Non-Recurring"),
                Forms\Components\Checkbox::make('onlaunch')->label("Add on Project Creation"),
            ]);
    }

    public static function table(Table $table) : Table
    {
        return $table
            ->columns([
                TextColumn::make('name'),
                TextColumn::make('key'),
                CheckboxColumn::make('onetime')->label("One Time Only"),
                CheckboxColumn::make('onlaunch')->label("Project Creation")
            ])
            ->defaultSort('name')
            ->filters([
                //
            ])
            ->actions([
                Tables\Actions\EditAction::make(),
            ])
            ->bulkActions([
                Tables\Actions\BulkActionGroup::make([
                    Tables\Actions\DeleteBulkAction::make(),
                ]),
            ]);
    }

    public static function getRelations() : array
    {
        return [
            //
        ];
    }

    public static function getPages() : array
    {
        return [
            'index'  => Pages\ListSchedules::route('/'),
            'create' => Pages\CreateSchedule::route('/create'),
            'edit'   => Pages\EditSchedule::route('/{record}/edit'),
        ];
    }

    public static function getEloquentQuery() : Builder
    {
        return parent::getEloquentQuery();
    }
}
Jehizkia commented 1 month ago

Thanks for reporting, I'll be looking into it!

Jehizkia commented 1 month ago

I can't seem to replicate this problem in the "Filament demo" project. Could you please share your EditSchedule.php? Also, what is the configuration of the active banner?

ap1969 commented 1 month ago

Hi, I'll try to replicate in a clean repo, but I'm on vacation at the moment so it'll be next week before I can

Andy.

Jehizkia commented 1 month ago

Hi Andy,

No problem, take your time. Enjoy your vacation!

ap1969 commented 1 month ago

Hi @Jehizkia

I think I found the issue:

  1. Create a filament resource as normal.
  2. Create a banner: Location = start of page, Banner Can Be Closed By The User = checked
  3. Go to the resource page and dismiss the banner
  4. Edit a resource, and click Delete
  5. Nothing happens.
  6. Click Delete again
  7. The normal filament delete confirmation appears.

I've tested on a clean laravel project, and got the same problem.

Hope that helps, Andy

Jehizkia commented 1 month ago

Hi @ap1969 ,

Thank you very much. I'll be looking into it furthermore 🙏

Stefano-Cecere commented 6 days ago

Same happens also on the resource table when clicking delete button on rows->nothing happens->banner disappear->click delete again->normal filament delete confirmation appears.

Hope there is a fix, Ste