From 0a7c631d30553a43a43d616f3947ac0bc6232113 Mon Sep 17 00:00:00 2001 From: Johannes Raggam Date: Fri, 11 Feb 2022 09:46:57 +0100 Subject: [PATCH] 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: https://github.com/Patternslib/Patterns/issues/961 --- src/pat/relateditems/relateditems.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pat/relateditems/relateditems.js b/src/pat/relateditems/relateditems.js index 73383ecb9..c592315bd 100644 --- a/src/pat/relateditems/relateditems.js +++ b/src/pat/relateditems/relateditems.js @@ -5,6 +5,7 @@ import Base from "@patternslib/patternslib/src/core/base"; import _t from "../../core/i18n-wrapper"; import utils from "../../core/utils"; import registry from "@patternslib/patternslib/src/core/registry"; +import Select2 from "../select2/select2"; const KEY = { LEFT: 37, @@ -503,7 +504,6 @@ export default Base.extend({ }, init: async function () { - const Select2 = (await import("../select2/select2")).default; (await import("bootstrap")).Dropdown; import("./relateditems.scss");