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

Prevent Flash JS when deleting a Matrix block on the frontend #2799

Closed
wants to merge 1 commit into from
Closed

Prevent Flash JS when deleting a Matrix block on the frontend #2799

wants to merge 1 commit into from

Conversation

tomwelch
Copy link

When deleting matrix blocks from the front end of the site a number of cpresources are injected into the page at reload adding additional styling and a number of errors in the console.

screen shot 2018-04-24 at 13 35 16

The afterDelete method in src/elements/MatrixBlock.php is injecting the cpresources to clean up the browser's Local Storage of collapsed matrix blocks. As we're deleting them from the frontend, we don't need this functionality so I've updated the if statement to check if the request is a site request as well as a console request, and if so, skip including the cpresources.

This issue has also come up on the Craft CMS StackExchange:
https://craftcms.stackexchange.com/questions/25637/craft-3-resaving-matrix-from-frontend-causing-issues-craft-is-not-defined

Added an additional check to MatrixBlock.php@afterDelete to see if the request is coming from the frontend and if so, skip adding the Flash JS that causes templating problems.
@brandonkelly
Copy link
Member

Thanks for pointing that out!

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

Successfully merging this pull request may close these issues.

2 participants