Skip to content

Commit 926de33

Browse files
committed
fix(pat-auto-suggest): Adapt to changes from pat-depends where the event is called on the pat-depends element itself.
1 parent 6152afd commit 926de33

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/pat/auto-suggest/auto-suggest.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,19 @@ export default Base.extend({
9494

9595
dom.hide(this.el); // hide input, but keep active (e.g. for validation)
9696

97-
this.$el.on("pat-update", (e, data) => {
98-
if (data?.pattern === "depends") {
99-
if (data?.enabled === true) {
100-
this.$el.select2("enable", true);
101-
} else if (data?.enabled === false) {
102-
this.$el.select2("disable", true);
97+
// Handle case of pat-depends, where select2 might not be visible initially
98+
const pat_depends = this.el.closest(".pat-depends");
99+
if (pat_depends) {
100+
$(pat_depends).on("pat-update", (e, data) => {
101+
if (data?.pattern === "depends") {
102+
if (data?.enabled === true) {
103+
this.$el.select2("enable", true);
104+
} else if (data?.enabled === false) {
105+
this.$el.select2("disable", true);
106+
}
103107
}
104-
}
105-
});
108+
});
109+
}
106110

107111
// Allow pat-validate to check for validity when select2 was interacted
108112
// with but no value selected.

0 commit comments

Comments
 (0)