lisichatbot 1.8.4 → 1.8.6

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +23 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisichatbot",
3
- "version": "1.8.4",
3
+ "version": "1.8.6",
4
4
  "type": "module",
5
5
  "main": "./src/index.js",
6
6
  "exports": {
package/src/index.js CHANGED
@@ -587,7 +587,7 @@ function renderOptions(options, field, isSingleSelect = true) {
587
587
  const optionsWrapper = document.createElement('div');
588
588
  optionsWrapper.setAttribute('data-chat-element', 'options-wrapper');
589
589
  optionsWrapper.style.display = 'flex';
590
- optionsWrapper.style.flexDirection = 'column';
590
+ optionsWrapper.style.flexWrap = 'wrap';
591
591
  optionsWrapper.style.alignItems = 'flex-start';
592
592
  optionsWrapper.style.gap = '8px';
593
593
 
@@ -726,7 +726,7 @@ function renderColorOptions(options, field) {
726
726
  const optionsWrapper = document.createElement('div');
727
727
  optionsWrapper.setAttribute('data-chat-element', 'options-wrapper');
728
728
  optionsWrapper.style.display = 'flex';
729
- optionsWrapper.style.flexDirection = 'column';
729
+ optionsWrapper.style.flexWrap = 'wrap';
730
730
  optionsWrapper.style.alignItems = 'flex-start';
731
731
  optionsWrapper.style.gap = '8px';
732
732
 
@@ -862,7 +862,7 @@ function renderCustomSelectOptions(options, field, customConfig) {
862
862
  const optionsWrapper = document.createElement('div');
863
863
  optionsWrapper.setAttribute('data-chat-element', 'options-wrapper');
864
864
  optionsWrapper.style.display = 'flex';
865
- optionsWrapper.style.flexDirection = 'column';
865
+ optionsWrapper.style.flexWrap = 'wrap';
866
866
  optionsWrapper.style.alignItems = 'flex-start';
867
867
  optionsWrapper.style.gap = '8px';
868
868
 
@@ -3270,6 +3270,26 @@ function init(flowName, flowConfig, options = {}) {
3270
3270
  elements.originalNextBtnText = 'Next';
3271
3271
  }
3272
3272
 
3273
+ // ✅ CRITICAL: Move back any injected elements BEFORE clearing innerHTML
3274
+ // This prevents elements from being permanently deleted on re-initialization
3275
+ const existingInjected = elements.messages.querySelectorAll('[data-chat-injected="true"]');
3276
+ if (existingInjected.length > 0) {
3277
+ console.log(` ↩️ Moving back ${existingInjected.length} injected element(s) before clearing (re-init)`);
3278
+ existingInjected.forEach(el => {
3279
+ el.style.display = 'none';
3280
+ el.removeAttribute('data-chat-injected');
3281
+
3282
+ // Move back to original parent
3283
+ if (el._originalParent && document.contains(el._originalParent)) {
3284
+ if (el._originalNextSibling && el._originalParent.contains(el._originalNextSibling)) {
3285
+ el._originalParent.insertBefore(el, el._originalNextSibling);
3286
+ } else {
3287
+ el._originalParent.appendChild(el);
3288
+ }
3289
+ }
3290
+ });
3291
+ }
3292
+
3273
3293
  elements.messages.innerHTML = '';
3274
3294
 
3275
3295
  elements.nextBtn.disabled = true;