lisichatbot 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.js +28 -1
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -284,6 +284,7 @@ function renderMultiSelectDropdown(options, field) {
|
|
|
284
284
|
const optionTemplate = clone.querySelector('[data-chat-input-element="dropdown-option-wrapper"]');
|
|
285
285
|
const tagsContainer = clone.querySelector('[data-chat-input-element="tags-container"]');
|
|
286
286
|
const tagTemplate = clone.querySelector('[data-chat-input-element="tag-wrapper"]');
|
|
287
|
+
const dropdownInput = clone.querySelector('[data-chat-input-element="dropdown-input"]'); // ✅ NEW
|
|
287
288
|
|
|
288
289
|
if (!dropdown || !optionsWrapper || !searchBar || !optionsContainer || !optionTemplate || !tagsContainer || !tagTemplate) {
|
|
289
290
|
console.error('Multi-select dropdown: Missing required elements');
|
|
@@ -294,7 +295,8 @@ function renderMultiSelectDropdown(options, field) {
|
|
|
294
295
|
optionsContainer: !!optionsContainer,
|
|
295
296
|
optionTemplate: !!optionTemplate,
|
|
296
297
|
tagsContainer: !!tagsContainer,
|
|
297
|
-
tagTemplate: !!tagTemplate
|
|
298
|
+
tagTemplate: !!tagTemplate,
|
|
299
|
+
dropdownInput: !!dropdownInput // ✅ NEW
|
|
298
300
|
});
|
|
299
301
|
return;
|
|
300
302
|
}
|
|
@@ -317,6 +319,17 @@ function renderMultiSelectDropdown(options, field) {
|
|
|
317
319
|
const existingData = disablePrefill ? [] : (chatState.data[field] || []);
|
|
318
320
|
const selectedValues = new Set(existingData);
|
|
319
321
|
|
|
322
|
+
// ✅ NEW: Set initial dropdown-input visibility based on pre-filled data
|
|
323
|
+
if (dropdownInput) {
|
|
324
|
+
if (existingData.length > 0) {
|
|
325
|
+
dropdownInput.style.display = 'none';
|
|
326
|
+
console.log(` 🙈 Dropdown input hidden initially (${existingData.length} pre-filled selection${existingData.length === 1 ? '' : 's'})`);
|
|
327
|
+
} else {
|
|
328
|
+
dropdownInput.style.display = '';
|
|
329
|
+
console.log(` 👁️ Dropdown input visible initially (no pre-filled selections)`);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
320
333
|
if (disablePrefill) {
|
|
321
334
|
console.log(`⏭️ Pre-fill disabled for ${field} - starting fresh`);
|
|
322
335
|
} else {
|
|
@@ -538,11 +551,25 @@ function renderMultiSelectDropdown(options, field) {
|
|
|
538
551
|
enableNextButton();
|
|
539
552
|
}
|
|
540
553
|
}
|
|
554
|
+
|
|
555
|
+
// ✅ NEW: Re-render tags to update dropdown-input visibility
|
|
556
|
+
renderTags(field, options, tagsContainer, tagTemplate, optionsContainer);
|
|
541
557
|
};
|
|
542
558
|
}
|
|
543
559
|
|
|
544
560
|
tagsContainer.appendChild(tagEl);
|
|
545
561
|
});
|
|
562
|
+
|
|
563
|
+
// ✅ NEW: Show/hide dropdown-input based on tag count
|
|
564
|
+
if (dropdownInput) {
|
|
565
|
+
if (selections.length > 0) {
|
|
566
|
+
dropdownInput.style.display = 'none';
|
|
567
|
+
console.log(` 🙈 Dropdown input hidden (${selections.length} tag${selections.length === 1 ? '' : 's'} displayed)`);
|
|
568
|
+
} else {
|
|
569
|
+
dropdownInput.style.display = '';
|
|
570
|
+
console.log(` 👁️ Dropdown input visible (no tags)`);
|
|
571
|
+
}
|
|
572
|
+
}
|
|
546
573
|
}
|
|
547
574
|
|
|
548
575
|
// ✅ Initial tag render if pre-filled (edit mode)
|