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

fix: Unmounting actions dispatches close-modal when modal is already closed #14200

Merged
merged 2 commits into from
Sep 11, 2024

Conversation

wout-o
Copy link
Contributor

@wout-o wout-o commented Sep 11, 2024

Description

This addresses the issue described in #10581.

The modal's close() function already closes the current modal and it also dispatches the modal-closed event, which when caught will cause the action's unmount function to be called. This function, however, does not take this into account and will always dispatch the close-modal event again.

This PR introduces a new variable $shouldDispatchCloseModal for the actions' unmount function, which when set to false will prevent the close-modal event from being dispatched again. Since this variable has a default value of true it should not break any other uses of the functions.

Visual changes

Improved UX when rapidly closing and reopening modals on complex pages or when the user has a slower connection.

Actions

Delete button
Before: https://demo.filamentphp.com/shop/orders/1/edit
After: https://demo.filament.thenines.be/shop/orders/1/edit

Table actions

Edit button
Before: https://demo.filamentphp.com/blog/categories
After: https://demo.filament.thenines.be/blog/categories

Form actions

Reset button
Before: https://demo.filamentphp.com/shop/orders/1/edit
After: https://demo.filament.thenines.be/shop/orders/1/edit

Infolist Actions

Author's suffix action
Before: not present in the demo
After: https://demo.filament.thenines.be/blog/posts/1

Functional changes

  • Code style has been fixed by running the composer cs command.
  • Changes have been tested to not break existing functionality.
  • Documentation is up-to-date.

@danharrin danharrin added the bug Something isn't working label Sep 11, 2024
@danharrin danharrin added this to the v3 milestone Sep 11, 2024
@danharrin danharrin linked an issue Sep 11, 2024 that may be closed by this pull request
@danharrin
Copy link
Member

This looks great, thank you so much for taking the time!

@danharrin danharrin merged commit 41b2aef into filamentphp:3.x Sep 11, 2024
10 checks passed
@danharrin danharrin mentioned this pull request Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Modal Actions
2 participants