@internetarchive/ia-topnav 1.3.5-alpha18 → 1.3.5-alpha19

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": "@internetarchive/ia-topnav",
3
- "version": "1.3.5-alpha18",
3
+ "version": "1.3.5-alpha19",
4
4
  "description": "Top nav for Internet Archive",
5
5
  "license": "AGPL-3.0-only",
6
6
  "main": "index.js",
package/src/ia-topnav.js CHANGED
@@ -204,7 +204,7 @@ export default class IATopNav extends LitElement {
204
204
  tabindex="${this.userMenuTabIndex}"
205
205
  @menuToggled=${this.menuToggled}
206
206
  @trackClick=${this.trackClick}
207
- @focusToNext=${(e) => this.currentTab = e.detail}
207
+ @focusToOtherMenuItem=${(e) => this.currentTab = e.detail}
208
208
  ></user-menu>
209
209
  `;
210
210
  }
@@ -297,7 +297,7 @@ export default class IATopNav extends LitElement {
297
297
  .mediaSliderOpen=${this.mediaSliderOpen}
298
298
  .menus=${this.menus}
299
299
  tabindex="${this.mediaSliderOpen ? '1' : '-1'}"
300
- @focusToNext=${(e) => this.currentTab = e.detail}
300
+ @focusToOtherMenuItem=${(e) => this.currentTab = e.detail}
301
301
  ></media-slider>
302
302
  </div>
303
303
  ${this.username ? this.userMenu : this.signedOutDropdown}
@@ -69,7 +69,7 @@ export default class KeyboardNavigation {
69
69
  }
70
70
 
71
71
  /**
72
- * Handles arrow key events and focuses the next or previous element.
72
+ * Handles arrow key events and focuses the next or previous element for topnav sub-nav and usermenu
73
73
  * @param {string} key - The key that was pressed ('ArrowDown', 'ArrowRight', 'ArrowUp', or 'ArrowLeft').
74
74
  */
75
75
  handleArrowKey(key) {
@@ -102,7 +102,7 @@ export default class KeyboardNavigation {
102
102
  handleTabKey(event) {
103
103
  if (this.menuOption) {
104
104
  const isShiftPressed = event.shiftKey;
105
- this.focusNextMenuItem(isShiftPressed);
105
+ this.focusToOtherMenuItems(isShiftPressed);
106
106
  }
107
107
 
108
108
  this.focusableElements[this.focusedIndex]?.blur();
@@ -110,12 +110,12 @@ export default class KeyboardNavigation {
110
110
  }
111
111
 
112
112
  /**
113
- * Focuses the next or previous menu item based on the provided flag.
113
+ * Focuses the other parent menu items based on the provided flag.
114
114
  * @param {boolean} isPrevious - A flag indicating whether to focus the previous menu item.
115
115
  */
116
- focusNextMenuItem(isPrevious = false) {
116
+ focusToOtherMenuItems(isPrevious = false) {
117
117
  this.elementsContainer.dispatchEvent(
118
- new CustomEvent('focusToNext', {
118
+ new CustomEvent('focusToOtherMenuItem', {
119
119
  bubbles: true,
120
120
  composed: true,
121
121
  detail: {
@@ -103,7 +103,6 @@ class MediaButton extends TrackedElement {
103
103
  @click=${this.followable ? this.trackClick : this.onClick}
104
104
  data-event-click-tracking="${this.analyticsEvent}"
105
105
  title="${this.tooltipPrefix} ${this.mediatype} menu"
106
- tabindex="${this.openMenu === 'media' ? '' : '0'}"
107
106
  >
108
107
  ${this.menuItem}
109
108
  </a>
package/src/media-menu.js CHANGED
@@ -90,7 +90,8 @@ class MediaMenu extends LitElement {
90
90
  linkItem.classList.remove('selected');
91
91
  linkItem.blur();
92
92
 
93
- mediaButtons[this.currentTab.moveTo === 'next' ? index + 1 : index - 1].shadowRoot.querySelector('a.menu-item').focus();
93
+ const newFocusIndex = this.currentTab.moveTo === 'next' ? index + 1 : index - 1;
94
+ mediaButtons[newFocusIndex].shadowRoot.querySelector('a.menu-item').focus();
94
95
  }
95
96
  }
96
97
  });