@momentum-design/components 0.133.0 → 0.133.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.
|
@@ -343,9 +343,8 @@ class Combobox extends KeyDownHandledMixin(KeyToActionMixin(CaptureDestroyEventF
|
|
|
343
343
|
this.lastCommittedValue = value;
|
|
344
344
|
this.internals.setFormValue(this.value);
|
|
345
345
|
this.updateHiddenOptions();
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
}
|
|
346
|
+
this.updateSelectedOption(option);
|
|
347
|
+
this.resetFocusedOption();
|
|
349
348
|
this.setInputValidity();
|
|
350
349
|
this.resetHelpText();
|
|
351
350
|
if (emitEvents && !updateFromValue && option) {
|
|
@@ -388,21 +387,25 @@ class Combobox extends KeyDownHandledMixin(KeyToActionMixin(CaptureDestroyEventF
|
|
|
388
387
|
// keep value-attribute based default selection working for both
|
|
389
388
|
// controlled and uncontrolled modes, while avoiding change/input events
|
|
390
389
|
// by delegating to setSelectedValue with updateFromValue=true.
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
390
|
+
// Skip the initial paint (oldValue === null with empty newValue) but allow
|
|
391
|
+
// programmatic clears (oldValue is a string when the attribute was already set).
|
|
392
|
+
if (name === 'value' && this.navItems.length && !(oldValue === null && newValue === '')) {
|
|
394
393
|
let optionToSelect = null;
|
|
395
|
-
if (
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
394
|
+
if (newValue !== '') {
|
|
395
|
+
const firstSelectedOption = this.getFirstSelectedOption();
|
|
396
|
+
const valueBasedOption = this.navItems.find(option => option.value === newValue);
|
|
397
|
+
if (valueBasedOption) {
|
|
398
|
+
optionToSelect = valueBasedOption;
|
|
399
|
+
}
|
|
400
|
+
else if (firstSelectedOption) {
|
|
401
|
+
optionToSelect = firstSelectedOption;
|
|
402
|
+
}
|
|
403
|
+
else if (this.placeholder) {
|
|
404
|
+
optionToSelect = null;
|
|
405
|
+
}
|
|
406
|
+
else {
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
406
409
|
}
|
|
407
410
|
this.updateComplete
|
|
408
411
|
.then(() => {
|
|
@@ -827,12 +830,9 @@ class Combobox extends KeyDownHandledMixin(KeyToActionMixin(CaptureDestroyEventF
|
|
|
827
830
|
if (this.disabled || this.readonly) {
|
|
828
831
|
return false;
|
|
829
832
|
}
|
|
830
|
-
if (optionsLength) {
|
|
833
|
+
if (optionsLength || this.noResultText) {
|
|
831
834
|
return this.isOpen;
|
|
832
835
|
}
|
|
833
|
-
if (this.noResultText) {
|
|
834
|
-
return true;
|
|
835
|
-
}
|
|
836
836
|
return false;
|
|
837
837
|
}
|
|
838
838
|
/**
|