@internetarchive/ia-topnav 1.3.4 → 1.3.5-alpha2

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.4",
3
+ "version": "1.3.5-alpha2",
4
4
  "description": "Top nav for Internet Archive",
5
5
  "license": "AGPL-3.0-only",
6
6
  "main": "index.js",
package/src/nav-search.js CHANGED
@@ -34,13 +34,6 @@ class NavSearch extends TrackedElement {
34
34
  this.initSearchBetaOptIn();
35
35
  }
36
36
 
37
- updated() {
38
- if (this.open) {
39
- this.shadowRoot.querySelector('[name=query]').focus();
40
- }
41
- return true;
42
- }
43
-
44
37
  initSearchBetaOptIn() {
45
38
  this.inSearchBeta = !!window.localStorage?.getItem('SearchBeta-opt-in') ||
46
39
  !!window.localStorage?.getItem('SearchBeta-launched');
@@ -105,6 +98,7 @@ class NavSearch extends TrackedElement {
105
98
  class="search-field"
106
99
  placeholder="Search"
107
100
  autocomplete="off"
101
+ tabindex="2"
108
102
  @focus=${this.toggleSearchMenu}
109
103
  value=${this.searchQuery || ''}
110
104
  />
@@ -112,6 +106,7 @@ class NavSearch extends TrackedElement {
112
106
  <button
113
107
  type="submit"
114
108
  class="search"
109
+ tabindex="-1"
115
110
  data-event-click-tracking="${this.config.eventCategory}|NavSearchClose"
116
111
  >
117
112
  ${icons.search}
@@ -87,6 +87,7 @@ class PrimaryNav extends TrackedElement {
87
87
  <button
88
88
  class="user-menu ${userMenuClass}"
89
89
  title="${userMenuToolTip}"
90
+ tabindex="-1"
90
91
  @click="${this.toggleUserMenu}"
91
92
  data-event-click-tracking="${this.config.eventCategory}|NavUserMenu"
92
93
  >
@@ -106,6 +107,7 @@ class PrimaryNav extends TrackedElement {
106
107
  .config=${this.config}
107
108
  .dropdownOpen=${this.signedOutMenuOpen}
108
109
  .openMenu=${this.openMenu}
110
+ tabindex="-1"
109
111
  @signedOutMenuToggled=${this.signedOutMenuToggled}
110
112
  ></login-button>
111
113
  `;
@@ -152,7 +154,15 @@ class PrimaryNav extends TrackedElement {
152
154
  }
153
155
 
154
156
  get uploadButtonTemplate() {
155
- return html`<a href="${formatUrl('/create', this.baseHost)}" class="upload">
157
+ return html`
158
+ <a href="${formatUrl('/create', this.baseHost)}"
159
+ class="upload"
160
+ tabindex="1"
161
+ @focus=${(e) => {
162
+ if (e.relatedTarget !== null) {
163
+ this.toggleSearchMenu(e)
164
+ }
165
+ }}>
156
166
  ${icons.upload}
157
167
  <span>Upload</span>
158
168
  </a>`;
@@ -188,6 +198,7 @@ class PrimaryNav extends TrackedElement {
188
198
  data-event-click-tracking="${this.config.eventCategory}|NavHome"
189
199
  title="Go home"
190
200
  class="link-home"
201
+ tabindex="-1"
191
202
  >${icons.iaLogo}${logoWordmarkStacked}</a
192
203
  >
193
204
  ${this.secondLogoSlot}
@@ -29,6 +29,29 @@ class SearchMenu extends TrackedElement {
29
29
  this.selectedSearchType = '';
30
30
  }
31
31
 
32
+ firstUpdated() {
33
+ this.shadowRoot.addEventListener('keyup', (e) => {
34
+ const searchTypes = this.shadowRoot.querySelectorAll('.search-menu-inner label input[type=radio]');
35
+ const length = searchTypes.length - 1;
36
+
37
+ // early return if searchTypes not found
38
+ if (!length) return;
39
+
40
+ const searchTypeHandler = (index) => {
41
+ const searchType = searchTypes[index];
42
+ searchType.checked = true;
43
+ searchType.dispatchEvent(new Event('change'));
44
+ searchType.focus();
45
+ };
46
+
47
+ if (e.key === 'Home') {
48
+ searchTypeHandler(0);
49
+ } else if (e.key === 'End') {
50
+ searchTypeHandler(length);
51
+ }
52
+ });
53
+ }
54
+
32
55
  selectSearchType(e) {
33
56
  this.selectedSearchType = e.target.value;
34
57
  }
@@ -70,7 +93,7 @@ class SearchMenu extends TrackedElement {
70
93
  }
71
94
  return html`
72
95
  <label @click="${this.selectSearchType}">
73
- <input form="nav-search" type="radio" name="sin" value="${value}" ?checked=${isDefault} @change=${this.searchInChanged} />
96
+ <input tabindex="3" form="nav-search" type="radio" name="sin" value="${value}" ?checked=${isDefault} @change=${this.searchInChanged} />
74
97
  Search ${label}
75
98
  </label>
76
99
  `;
@@ -104,6 +127,7 @@ class SearchMenu extends TrackedElement {
104
127
  href="${formatUrl('/advancedsearch.php', this.baseHost)}"
105
128
  @click=${this.trackClick}
106
129
  data-event-click-tracking="${this.config.eventCategory}|NavAdvancedSearch"
130
+ tabindex="4"
107
131
  >Advanced Search</a
108
132
  >
109
133
  </div>
@@ -43,6 +43,9 @@ export default css`
43
43
  .advanced-search {
44
44
  text-decoration: none;
45
45
  color: var(--linkColor);
46
+ line-height: normal;
47
+ padding: 0.5rem;
48
+ margin-top: 5px;
46
49
  }
47
50
 
48
51
  @media (min-width: 890px) {