banner icon indicating copy to clipboard operation
banner copied to clipboard

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

Open ap1969 opened this issue 1 year ago • 6 comments

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

  • Install the package
  • Enable it for a panel.

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();
    }
}

ap1969 avatar Jul 13 '24 13:07 ap1969

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

Jehizkia avatar Jul 15 '24 07:07 Jehizkia

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?

Jehizkia avatar Jul 15 '24 12:07 Jehizkia

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.

ap1969 avatar Jul 18 '24 23:07 ap1969

Hi Andy,

No problem, take your time. Enjoy your vacation!

Jehizkia avatar Jul 19 '24 06:07 Jehizkia

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

ap1969 avatar Jul 25 '24 20:07 ap1969

Hi @ap1969 ,

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

Jehizkia avatar Aug 03 '24 10:08 Jehizkia

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

Stefano-Cecere avatar Sep 05 '24 09:09 Stefano-Cecere