@ni/nimble-components 11.8.4 → 11.8.5

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.
@@ -16739,9 +16739,7 @@
16739
16739
  class Combobox extends Combobox$1 {
16740
16740
  constructor() {
16741
16741
  super(...arguments);
16742
- this.focusOutHandler = () => {
16743
- this.open = false;
16744
- };
16742
+ this.valueUpdatedByInput = false;
16745
16743
  }
16746
16744
  // Workaround for https://github.com/microsoft/fast/issues/5123
16747
16745
  setPositioning() {
@@ -16765,10 +16763,6 @@
16765
16763
  // Call setPositioning() after this.forcedPosition is initialized.
16766
16764
  this.setPositioning();
16767
16765
  this.updateInputAriaLabel();
16768
- this.addEventListener('focusout', this.focusOutHandler);
16769
- }
16770
- disconnectedCallback() {
16771
- this.removeEventListener('focusout', this.focusOutHandler);
16772
16766
  }
16773
16767
  toggleButtonClickHandler(e) {
16774
16768
  e.stopImmediatePropagation();
@@ -16795,6 +16789,50 @@
16795
16789
  const enabledOptions = this.filteredOptions.filter(o => !o.disabled);
16796
16790
  this.filteredOptions = enabledOptions;
16797
16791
  }
16792
+ /**
16793
+ * This is a workaround for the issue described here: https://github.com/microsoft/fast/issues/6267
16794
+ * For now, we will update the value ourselves while a user types in text. Note that there is other
16795
+ * implementation related to this (like the 'keydownEventHandler') needed to create the complete set
16796
+ * of desired behavior described in the issue noted above.
16797
+ */
16798
+ // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
16799
+ inputHandler(e) {
16800
+ const returnValue = super.inputHandler(e);
16801
+ if (!this.valueUpdatedByInput) {
16802
+ this.valueBeforeTextUpdate = this.value;
16803
+ }
16804
+ this.value = this.control.value;
16805
+ this.valueUpdatedByInput = true;
16806
+ return returnValue;
16807
+ }
16808
+ // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
16809
+ keydownHandler(e) {
16810
+ const returnValue = super.keydownHandler(e);
16811
+ if (e.ctrlKey || e.altKey) {
16812
+ return returnValue;
16813
+ }
16814
+ switch (e.key) {
16815
+ case keyEnter:
16816
+ this.emitChangeIfValueUpdated();
16817
+ break;
16818
+ case keyArrowDown:
16819
+ case keyArrowUp:
16820
+ if (this.open && this.valueUpdatedByInput) {
16821
+ this.valueUpdatedByInput = false;
16822
+ }
16823
+ break;
16824
+ default:
16825
+ return returnValue;
16826
+ }
16827
+ return returnValue;
16828
+ }
16829
+ // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
16830
+ focusoutHandler(e) {
16831
+ const returnValue = super.focusoutHandler(e);
16832
+ this.open = false;
16833
+ this.emitChangeIfValueUpdated();
16834
+ return returnValue;
16835
+ }
16798
16836
  openChanged() {
16799
16837
  super.openChanged();
16800
16838
  if (this.dropdownButton) {
@@ -16814,6 +16852,24 @@
16814
16852
  inputElement?.removeAttribute('aria-label');
16815
16853
  }
16816
16854
  }
16855
+ /**
16856
+ * This will only emit a `change` event after text entry where the text in the input prior to
16857
+ * typing is different than the text present upon an attempt to commit (e.g. pressing <Enter>).
16858
+ * So, for a concrete example:
16859
+ * 1) User types 'Sue' (when Combobox input was blank).
16860
+ * 2) User presses <Enter> -> 'change' event fires
16861
+ * 3) User deletes 'Sue'
16862
+ * 4) User re-types 'Sue'
16863
+ * 5) User presses <Enter> -> NO 'change' event is fired
16864
+ */
16865
+ emitChangeIfValueUpdated() {
16866
+ if (this.valueUpdatedByInput) {
16867
+ if (this.value !== this.valueBeforeTextUpdate) {
16868
+ this.$emit('change');
16869
+ }
16870
+ this.valueUpdatedByInput = false;
16871
+ }
16872
+ }
16817
16873
  }
16818
16874
  __decorate([
16819
16875
  observable