gd-bs 6.6.36 → 6.6.37

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.36",
3
+ "version": "6.6.37",
4
4
  "description": "Bootstrap JavaScript, TypeScript and Web Components library.",
5
5
  "main": "build/index.js",
6
6
  "typings": "src/index.d.ts",
@@ -167,8 +167,6 @@ class _Dropdown extends Base<IDropdownProps> implements IDropdown {
167
167
  if (menu) {
168
168
  // Add a change event
169
169
  menu.addEventListener("change", ev => {
170
- let values = "";
171
-
172
170
  // See if multiple options are allowed
173
171
  if (this.props.multi == true) {
174
172
  // See if we are selecting the values
@@ -179,9 +177,6 @@ class _Dropdown extends Base<IDropdownProps> implements IDropdown {
179
177
 
180
178
  // Update the flag
181
179
  item.isSelected = (item.el as HTMLOptionElement).selected;
182
-
183
- // Append the value
184
- values = (values ? ", " : "") + (item.props.text || item.props.value);
185
180
  }
186
181
  }
187
182
 
@@ -191,9 +186,6 @@ class _Dropdown extends Base<IDropdownProps> implements IDropdown {
191
186
  // Get the selected value
192
187
  let selectedValue = ((ev.target as HTMLSelectElement).value || "").trim();
193
188
 
194
- // Set the selected value
195
- values = selectedValue;
196
-
197
189
  // Parse the items
198
190
  for (let i = 0; i < this._items.length; i++) {
199
191
  let item = this._items[i];
@@ -214,15 +206,6 @@ class _Dropdown extends Base<IDropdownProps> implements IDropdown {
214
206
  }
215
207
  }
216
208
  }
217
-
218
- // See if we are updating the label
219
- if (this.props.updateLabel) {
220
- // Set the label
221
- let toggle = this.el.querySelector(".dropdown-toggle");
222
- if (toggle) {
223
- toggle.innerHTML = values || this.props.label;
224
- }
225
- }
226
209
  });
227
210
  }
228
211
 
@@ -346,6 +329,22 @@ class _Dropdown extends Base<IDropdownProps> implements IDropdown {
346
329
  selectedItem.toggle();
347
330
  }
348
331
  }
332
+
333
+ // See if we are updating the label
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
+ }
341
+
342
+ // Set the label
343
+ let toggle = this.el.querySelector(".dropdown-toggle");
344
+ if (toggle) {
345
+ toggle.innerHTML = selectedValues.length > 0 ? selectedValues.join(', ') : this.props.label;
346
+ }
347
+ }
349
348
  });
350
349
  }
351
350
 
@@ -362,6 +361,17 @@ class _Dropdown extends Base<IDropdownProps> implements IDropdown {
362
361
 
363
362
  // Execute the event
364
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;
368
+
369
+ // Set the label
370
+ let toggle = this.el.querySelector(".dropdown-toggle");
371
+ if (toggle) {
372
+ toggle.innerHTML = selectedItem ? selectedItem.text : this.props.label;
373
+ }
374
+ }
365
375
  });
366
376
  }
367
377