Skip to content

Commit 0b29633

Browse files
committed
refactor lookup component.
1 parent 9ff701b commit 0b29633

File tree

1 file changed

+8
-14
lines changed
  • packages/Webkul/Admin/src/Resources/views/components/form/control-group/controls/inline

1 file changed

+8
-14
lines changed

packages/Webkul/Admin/src/Resources/views/components/form/control-group/controls/inline/lookup.blade.php

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,6 @@ class="item-center flex justify-center bg-red-100 p-1 hover:bg-red-200 ltr:round
235235
dropdownPosition: "bottom",
236236
237237
isRTL: document.documentElement.dir === 'rtl',
238-
239-
uniqueId: Math.floor(100000 + Math.random() * 900000),
240238
};
241239
},
242240
@@ -258,15 +256,7 @@ class="item-center flex justify-center bg-red-100 p-1 hover:bg-red-200 ltr:round
258256
mounted() {
259257
window.addEventListener("resize", this.setDropdownPosition);
260258
261-
this.$emitter.on('lookup-dropdown-opened', (data) => {
262-
if (data.componentId !== this.uniqueId) {
263-
this.showPopup = false;
264-
}
265-
});
266-
},
267-
268-
beforeUnmount() {
269-
this.$emitter.off('lookup-dropdown-opened');
259+
this.$emitter.on('show-pop', this.handleShowPop);
270260
},
271261
272262
computed: {
@@ -307,12 +297,16 @@ class="item-center flex justify-center bg-red-100 p-1 hover:bg-red-200 ltr:round
307297
},
308298
309299
toggleEditor() {
310-
this.$emitter.emit('lookup-dropdown-opened', { componentId: this.uniqueId });
300+
this.$emitter.emit('show-pop', this.$.uid);
301+
},
311302
312-
this.showPopup = ! this.showPopup;
303+
handleShowPop(uid) {
304+
this.showPopup = (uid === this.$.uid);
313305
314306
if (this.showPopup) {
315-
this.$nextTick(() => this.$refs.searchInput.focus());
307+
this.$nextTick(() => this.$refs.searchInput?.focus());
308+
} else {
309+
this.isEditing = false;
316310
}
317311
},
318312

0 commit comments

Comments
 (0)