Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modalDescription method doesn't update view for Create action requiresConfirmation overlay #12877

Closed
MikeCodesSomething opened this issue May 21, 2024 · 3 comments
Labels

Comments

@MikeCodesSomething
Copy link

MikeCodesSomething commented May 21, 2024

Package

filament/forms

Package Version

v3.2.72

Laravel Version

v11.5.0

Livewire Version

v3.4.11

PHP Version

v8.3.6

Problem description

When adding a confirmation modal to the create action using the requireConfirmation() method, I can set a modalTitle as expected, however setting modalDescription does not overwrite the description.

Looking at the code, I think the issue is in:
/filament/actions/src/Concerns/CanRequireConfirmation.php

If I overwrite the $this->modalDescription line to be:
$this->modalDescription ??= fn (MountableAction $action): ?string => $action->evaluate($condition) ? __('filament-actions::modal.confirmation') : null;

it works for my use case. However I have no clue if this breaks other things.

Expected behavior

I expect the description of the confirmation modal to be overwritten from the default "Are you sure you would like to do this?" to the value I provided,

Steps to reproduce

On the Create page for any resource (e.g. CreateSheet), add the following code into the class to turn on the confirmation modal, the title will be correctly set to 'TEST', but the description won't get set to 'TEST2'

    protected function getCreateFormAction(): Action
    {
        return Action::make('create')
            ->modalHeading('TEST')
            ->modalDescription('TEST2')
            ->requiresConfirmation()
            ->action(fn () => $this->create());
    }

To replicate on the reproduction repository, create a user (in the db) and then try and create a sheet record, when you click 'create' and see the modal you won't get TEST2 as the modal description.

Reproduction repository

https://github.com/MikeCodesSomething/filament-create-modal-description-replication/

Relevant log output

No response

@andrewdwallo
Copy link
Contributor

@MikeCodesSomething Try rearranging your code to this:

protected function getCreateFormAction(): Action
{
    return Action::make('create')
        ->modalHeading('TEST')
        ->requiresConfirmation()
        ->modalDescription('TEST2')
        ->action(fn () => $this->create());
}

I suppose the order of the methods defined matters in this case. I would still constitute this as a bug though.

@danharrin
Copy link
Member

Check out the content of requiresConfirmation(), it is a shortcut for setting the description, hence this behaviour

@danharrin danharrin closed this as not planned Won't fix, can't repro, duplicate, stale May 29, 2024
@MikeCodesSomething
Copy link
Author

Thanks both!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

No branches or pull requests

3 participants