Easyadminbundle: No confirmation alert on leaving edit page after changes with WYSIWYG editor

Created on 3 Sep 2020  路  3Comments  路  Source: EasyCorp/EasyAdminBundle

Describe the bug
When I do some changes in WYSIWYG editor:
Screenshot 2020-09-03 at 19 43 02

And reload the page forgetting saving the changes - no confirmation alert as for other fields. I expect this:
Screenshot 2020-09-03 at 19 43 36

To Reproduce

  1. Go to edit page
  2. Edit content in the WYSIWYG editor
  3. Reload the page
bug confirmed help wanted

All 3 comments

These fields are very special because they are created dynamically with JavaScript.

We add for example some JS code to add the validation error messages in them (because the client-side browser HTML5 validation doesn't work either).

So, we'd need o check if the jQuery plugin we use for this _"There are unsaved changes"_ feature support this ... otherwise, we'd need to add some custom code to take care of this.

I don't have time for this ... so I hope someone from the community gives a try. Thanks! _(we'll merge it unless the fix requires a ton of changes)_.

I did a quick test and with adding the following to assets/js/form-type-text-editor.js we could enable the warning for the TextEditorField:

document.addEventListener("trix-change", function (event) {
  $(event.target).parents("form").trigger("checkform.areYouSure");
});

The solution for the CodeEditorField would probably look similar.

I don't have time for a PR this week, but meanwhile an easy workaround would be:

  • create a custom js file with above lines
  • use configureAssets() in your DashboardController to load the custom js (see https://symfony.com/doc/master/bundles/EasyAdminBundle/design.html#adding-custom-web-assets for details)

I created a PR https://github.com/EasyCorp/EasyAdminBundle/pull/3860 for the TrixEditor case - please let me know if it works for you

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Ealenn picture Ealenn  路  3Comments

tamert picture tamert  路  3Comments

devkbsc picture devkbsc  路  3Comments

liarco picture liarco  路  3Comments

haithem-rihane picture haithem-rihane  路  4Comments