plone / plone.patternslib

An add-on to make patternslib patterns available within Plone 5.
https://pypi.org/project/plone.patternslib/
GNU General Public License v2.0
2 stars 5 forks source link

Js error for select2 when installing this product #28

Closed cekk closed 5 years ago

cekk commented 5 years ago

Related with this post.

Environment: Plone 5.1 with only patternslib installed

Problem: if i try to edit a News Item with an image set, i have several js errors in the browser console like this:

patterns.pat.select2: Failed while initializing 'select2' pattern. query function not defined for Select2 s2id_autogen9

The strange thing is that if i unset the image, save it and go back in edit form, i don't have these errors. The problem seems related with this state.

I noticed that problem with a different content-type that have a relation field in default tab, and the widget is completely broken because of js errors in the console.

Another thing: if i enable js development-mode for plone bundle, the problem disappears.

It seems that something related to this product's bundles are in conflict with plone's default ones, but i can't find which one.

The main candidate should be select2. I was thinking that this is somehow duplicated in the patterns, but i can't find anything.

Any ideas?

cekk commented 5 years ago

@thet some ideas about how to fix/debug this?

thet commented 5 years ago

@cekk Yes, I saw this problem too - although not in own projects. See: https://community.plone.org/t/resources-registry-stub-js-modules-not-working-as-expected/7623

cekk commented 5 years ago

Following the thread on the forum, can i remove the registry init here? If yes, is there an official way to re-compile the bundle? In the README is mentioned a Makefile, but it seems disappeared.

thet commented 5 years ago

Yes, I'd say just remove the initialization code from https://github.com/plone/plone.patternslib/blob/master/src/plone/patternslib/static/bundle-leaflet.js and https://github.com/plone/plone.patternslib/blob/master/src/plone/patternslib/static/patterns.js Then - with plone.patternslib installed in your Plone site - just run ./bin/plone-compile-resources -b bundle-leaflet and ./bin/plone-compile-resources -b patterns, increase the last_compilation date for those and create a PR. There should be a upgrade step too.

cekk commented 5 years ago

Ok, solved with #29