@ni/nimble-components 35.5.1 → 35.5.2

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.
@@ -13466,6 +13466,12 @@
13466
13466
  * @internal
13467
13467
  */
13468
13468
  this.direction = Direction.ltr;
13469
+ /**
13470
+ * The collection of focusable toolbar controls.
13471
+ *
13472
+ * @internal
13473
+ */
13474
+ this.focusableElements = [];
13469
13475
  /**
13470
13476
  * The orientation of the toolbar.
13471
13477
  *
@@ -13486,7 +13492,7 @@
13486
13492
  }
13487
13493
  set activeIndex(value) {
13488
13494
  if (this.$fastController.isConnected) {
13489
- this._activeIndex = limit(0, this.focusableElements.length - 1, value);
13495
+ this._activeIndex = limit(0, this.focusableElements.length > 0 ? this.focusableElements.length - 1 : 0, value);
13490
13496
  Observable.notify(this, "activeIndex");
13491
13497
  }
13492
13498
  }
@@ -13501,7 +13507,7 @@
13501
13507
  * @internal
13502
13508
  */
13503
13509
  mouseDownHandler(e) {
13504
- const activeIndex = this.focusableElements?.findIndex(x => x.contains(e.target));
13510
+ const activeIndex = this.focusableElements.findIndex(x => x.contains(e.target));
13505
13511
  if (activeIndex > -1 && this.activeIndex !== activeIndex) {
13506
13512
  this.setFocusedElement(activeIndex);
13507
13513
  }
@@ -13558,7 +13564,7 @@
13558
13564
  return !e.target.closest("[role=radiogroup]");
13559
13565
  }
13560
13566
  const nextIndex = this.activeIndex + incrementer;
13561
- if (this.focusableElements[nextIndex]) {
13567
+ if (this.focusableElements.length > 0 && this.focusableElements[nextIndex]) {
13562
13568
  e.preventDefault();
13563
13569
  }
13564
13570
  this.setFocusedElement(nextIndex);
@@ -13581,7 +13587,7 @@
13581
13587
  * @internal
13582
13588
  */
13583
13589
  reduceFocusableElements() {
13584
- const previousFocusedElement = this.focusableElements?.[this.activeIndex];
13590
+ const previousFocusedElement = this.focusableElements[this.activeIndex];
13585
13591
  this.focusableElements = this.allSlottedItems.reduce(Toolbar.reduceFocusableItems, []);
13586
13592
  // If the previously active item is still focusable, adjust the active index to the
13587
13593
  // index of that item.
@@ -13598,7 +13604,8 @@
13598
13604
  setFocusedElement(activeIndex = this.activeIndex) {
13599
13605
  this.activeIndex = activeIndex;
13600
13606
  this.setFocusableElements();
13601
- if (this.focusableElements[this.activeIndex] &&
13607
+ if (this.focusableElements.length > 0 &&
13608
+ this.focusableElements[this.activeIndex] &&
13602
13609
  // Don't focus the toolbar element if some event handlers moved
13603
13610
  // the focus on another element in the page.
13604
13611
  this.contains(getRootActiveElement(this))) {