@fluid-topics/ftds-combobox 2.2.21 → 2.2.24

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.
@@ -180,7 +180,7 @@ export class FtdsBaseCombobox extends FtdsBaseComboboxBase {
180
180
  aria-selected="${isSelected}"
181
181
  data-active="${isActive}"
182
182
  @mousedown=${(e) => e.preventDefault()}
183
- @click=${() => this.onItemSelected(index)}
183
+ @click=${() => this.onItemSelected(suggestion)}
184
184
  >
185
185
  <div class="listbox-option--label">
186
186
  ${this.renderSuggestionItem(suggestion, isSelected)}
@@ -205,7 +205,7 @@ export class FtdsBaseCombobox extends FtdsBaseComboboxBase {
205
205
  aria-selected="${isSelected}"
206
206
  data-active="${isActive}"
207
207
  @mousedown=${(e) => e.preventDefault()}
208
- @click=${() => this.onItemSelected(index)}
208
+ @click=${() => this.onItemSelected(suggestion)}
209
209
  >
210
210
  ${this.renderNewValueTag()}
211
211
  ${when(isValidationErrors, () => this.renderNewValueValidationErrors(validationErrors), () => this.renderNewValueLabel(suggestion, isSelected))}
@@ -368,16 +368,15 @@ export class FtdsBaseCombobox extends FtdsBaseComboboxBase {
368
368
  this.isOpen = false;
369
369
  this.activeIndex = -1;
370
370
  }
371
- onItemSelected(index) {
371
+ onItemSelected(selected) {
372
372
  if (this.disabled) {
373
373
  return;
374
374
  }
375
- const suggestion = this.listboxItems[index];
376
- if (!suggestion) {
375
+ if (!selected) {
377
376
  return;
378
377
  }
379
- if (isActionableListboxItem(suggestion)) {
380
- this.commitSelection(suggestion);
378
+ if (isActionableListboxItem(selected)) {
379
+ this.commitSelection(selected);
381
380
  }
382
381
  }
383
382
  async onKeyDown(e) {
@@ -426,7 +425,8 @@ export class FtdsBaseCombobox extends FtdsBaseComboboxBase {
426
425
  }
427
426
  e.preventDefault();
428
427
  if (this.activeIndex >= 0) {
429
- this.onItemSelected(this.activeIndex);
428
+ const keyboardSelected = this.filteredSuggestions[this.activeIndex];
429
+ this.onItemSelected(keyboardSelected);
430
430
  }
431
431
  else {
432
432
  this.closeMenu();
@@ -18,7 +18,7 @@ export declare class FtdsComboboxMultiValue extends FtdsBaseCombobox<ComboboxVal
18
18
  isSuggestionSelected(value: string): boolean;
19
19
  private notifySelectionChange;
20
20
  private toggleSelectAll;
21
- renderListboxItem(listboxItem: ListboxItem, index: number): typeof import("lit-html").nothing | TemplateResult;
21
+ renderListboxItem(listboxItem: ListboxItem, index: number): typeof import("lit").nothing | TemplateResult;
22
22
  private renderSelectAll;
23
23
  private isValueSelected;
24
24
  private areAllSuggestionsChecked;
@@ -57,8 +57,6 @@ export class FtdsComboboxMultiValue extends FtdsBaseCombobox {
57
57
  else {
58
58
  this.value = this.value.filter((valueInSelection) => valueInSelection.value !== suggestion.value);
59
59
  }
60
- this.closeMenu();
61
- this.resetInputValue();
62
60
  this.notifySelectionChange([suggestion.label], shouldBeAdded);
63
61
  }
64
62
  commitTypedText() {
@@ -81,13 +79,9 @@ export class FtdsComboboxMultiValue extends FtdsBaseCombobox {
81
79
  this.dispatchEvent(new FtdsComboboxMultiValueChangeEvent(this.value));
82
80
  this.ariaDescribedBy = comboboxMultiValueContext.messages.numberOfSelectedValuesAriaLabel(this.value.length);
83
81
  const concatenatedSuggestions = suggestionsLabels.join();
84
- const message = isAdded
82
+ this.ariaLiveMessage = isAdded
85
83
  ? comboboxMultiValueContext.messages.valueAdded(concatenatedSuggestions)
86
84
  : comboboxMultiValueContext.messages.valueRemoved(concatenatedSuggestions);
87
- // Delay so VoiceOver finishes announcing the menu collapse before reading this message
88
- setTimeout(() => {
89
- this.ariaLiveMessage = message;
90
- }, 800);
91
85
  }
92
86
  toggleSelectAll() {
93
87
  const currentSuggestions = this.listboxItems
@@ -106,8 +100,6 @@ export class FtdsComboboxMultiValue extends FtdsBaseCombobox {
106
100
  diff = currentSuggestions.filter((s) => !this.value.some((selectedValue) => selectedValue.value === s.value));
107
101
  this.value = this.value.concat(diff);
108
102
  }
109
- this.closeMenu();
110
- this.resetInputValue();
111
103
  this.notifySelectionChange(diff.map((value) => value.label), !areAllSuggestionsChecked);
112
104
  }
113
105
  renderListboxItem(listboxItem, index) {
@@ -7,6 +7,7 @@ export declare class FtdsCombobox extends FtdsBaseCombobox<string> implements Ft
7
7
  static elementDefinitions: ElementDefinitionsMap;
8
8
  static styles: import("lit").CSSResult[];
9
9
  private previousCommittedLabel;
10
+ private updatedFromSelection;
10
11
  constructor();
11
12
  handleBlurStrategy(): void;
12
13
  private findSuggestionMatchingInput;
@@ -11,6 +11,7 @@ export class FtdsCombobox extends FtdsBaseCombobox {
11
11
  var _a;
12
12
  super();
13
13
  this.previousCommittedLabel = "";
14
+ this.updatedFromSelection = false;
14
15
  this.value = (_a = this.value) !== null && _a !== void 0 ? _a : "";
15
16
  }
16
17
  handleBlurStrategy() {
@@ -38,6 +39,7 @@ export class FtdsCombobox extends FtdsBaseCombobox {
38
39
  if (suggestion.type === ListboxItemType.newValue && processValidationRules(suggestion.value, this.newValueValidationRules).length > 0) {
39
40
  return;
40
41
  }
42
+ this.updatedFromSelection = true;
41
43
  this.commit(suggestion.value, suggestion.label);
42
44
  this.closeMenu();
43
45
  }
@@ -60,6 +62,10 @@ export class FtdsCombobox extends FtdsBaseCombobox {
60
62
  var _a;
61
63
  super.updated(changedProperties);
62
64
  if (changedProperties.has("value")) {
65
+ if (this.updatedFromSelection) {
66
+ this.updatedFromSelection = false;
67
+ return;
68
+ }
63
69
  const previous = (_a = (changedProperties.get("value"))) !== null && _a !== void 0 ? _a : "";
64
70
  const hasValueChanged = this.value !== previous && !this.isOpen && this.inputValue === this.previousCommittedLabel;
65
71
  if (hasValueChanged) {