Skip to content

Commit 0a7c631

Browse files
committed
fix(relateditems): Move Select2 out of init.
If it wasn't already registered, it would register and scan the document now. If there were previous relateditems already modifying the DOM structure and placing pat-select2 classes to some items, the import here would try to initialize them. But those pat-select2 items were meant to be initialized via the Patternslib API and not automatically and are missing some configuration needed by select2 (query attribute...). By moving the Select2 out of the init and importing it early fixes this problem. Note: This happened in plone.app.mosaic with module federation. pat-select2 was already directly imported by the main Mockup bundle. But since we didn't have a global pattern registry, the pattern was re-initialized where it wouldn't have to. Since the change in Patternslib 8.0.0 with a global pattern registry this fix might become obsolete. However, we should have an eye on dynamic pattern imports immediately registering and scanning the docment and possibly prevent that in some way. See: Patternslib/Patterns#961
1 parent 13d0e0d commit 0a7c631

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/pat/relateditems/relateditems.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import Base from "@patternslib/patternslib/src/core/base";
55
import _t from "../../core/i18n-wrapper";
66
import utils from "../../core/utils";
77
import registry from "@patternslib/patternslib/src/core/registry";
8+
import Select2 from "../select2/select2";
89

910
const KEY = {
1011
LEFT: 37,
@@ -503,7 +504,6 @@ export default Base.extend({
503504
},
504505

505506
init: async function () {
506-
const Select2 = (await import("../select2/select2")).default;
507507
(await import("bootstrap")).Dropdown;
508508
import("./relateditems.scss");
509509

0 commit comments

Comments
 (0)