gd-bs 6.6.38 → 6.6.39

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gd-bs",
3
- "version": "6.6.38",
3
+ "version": "6.6.39",
4
4
  "description": "Bootstrap JavaScript, TypeScript and Web Components library.",
5
5
  "main": "build/index.js",
6
6
  "typings": "src/index.d.ts",
@@ -332,17 +332,12 @@ class _Dropdown extends Base<IDropdownProps> implements IDropdown {
332
332
 
333
333
  // See if we are updating the label
334
334
  if (this.props.updateLabel) {
335
- let selectedItems = this.getValue() as IDropdownItem[];
336
- let selectedValues = [];
337
- for (let i = 0; i < selectedItems.length; i++) {
338
- // Append the value
339
- selectedValues.push(selectedItems[i].text);
340
- }
335
+ let selectedItem = this.getValue() as IDropdownItem;
341
336
 
342
337
  // Set the label
343
338
  let toggle = this.el.querySelector(".dropdown-toggle");
344
339
  if (toggle) {
345
- toggle.innerHTML = selectedValues.length > 0 ? selectedValues.join(', ') : this.props.label;
340
+ toggle.innerHTML = selectedItem ? selectedItem.text : this.props.label;
346
341
  }
347
342
  }
348
343
  });
@@ -358,20 +353,26 @@ class _Dropdown extends Base<IDropdownProps> implements IDropdown {
358
353
  // Toggle the menu if it's visible
359
354
  this.isVisible ? this.toggle() : null;
360
355
  }
361
-
362
- // Execute the event
363
- this.props.onChange ? this.props.onChange(this.getValue(), ev) : null;
364
-
365
- // See if we are updating the label
366
- if (this.props.updateLabel) {
367
- let selectedItem = this.getValue() as IDropdownItem;
356
+ // Else, see if we are updating the label for a multi-dropdown
357
+ else if (this.props.updateLabel) {
358
+ // Set the selected values
359
+ let selectedItems: IDropdownItem[] = this.getValue();
360
+ let selectedValues = [];
361
+ for (let i = 0; i < selectedItems.length; i++) {
362
+ // Append the value
363
+ selectedValues.push(selectedItems[i].text);
364
+ }
368
365
 
369
366
  // Set the label
370
367
  let toggle = this.el.querySelector(".dropdown-toggle");
371
368
  if (toggle) {
372
- toggle.innerHTML = selectedItem ? selectedItem.text : this.props.label;
369
+ // Set the label
370
+ toggle.innerHTML = selectedValues.length == 0 ? this.props.label : selectedValues.join(', ');
373
371
  }
374
372
  }
373
+
374
+ // Execute the event
375
+ this.props.onChange ? this.props.onChange(this.getValue(), ev) : null;
375
376
  });
376
377
  }
377
378