@internetarchive/ia-topnav 1.3.5-alpha2 → 1.3.5-alpha4
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 +1 -1
- package/src/nav-search.js +11 -0
- package/src/primary-nav.js +1 -6
- package/src/search-menu.js +27 -20
package/package.json
CHANGED
package/src/nav-search.js
CHANGED
|
@@ -100,6 +100,17 @@ class NavSearch extends TrackedElement {
|
|
|
100
100
|
autocomplete="off"
|
|
101
101
|
tabindex="2"
|
|
102
102
|
@focus=${this.toggleSearchMenu}
|
|
103
|
+
@blur=${(e) => {
|
|
104
|
+
if (e.relatedTarget?.tagName !== 'SEARCH-MENU') {
|
|
105
|
+
this.dispatchEvent(new CustomEvent('menuToggled', {
|
|
106
|
+
detail: {
|
|
107
|
+
menuName: 'search'
|
|
108
|
+
},
|
|
109
|
+
composed: true,
|
|
110
|
+
bubbles: true,
|
|
111
|
+
}));
|
|
112
|
+
}
|
|
113
|
+
}}
|
|
103
114
|
value=${this.searchQuery || ''}
|
|
104
115
|
/>
|
|
105
116
|
${this.searchInsideInput}
|
package/src/primary-nav.js
CHANGED
|
@@ -157,12 +157,7 @@ class PrimaryNav extends TrackedElement {
|
|
|
157
157
|
return html`
|
|
158
158
|
<a href="${formatUrl('/create', this.baseHost)}"
|
|
159
159
|
class="upload"
|
|
160
|
-
tabindex="1"
|
|
161
|
-
@focus=${(e) => {
|
|
162
|
-
if (e.relatedTarget !== null) {
|
|
163
|
-
this.toggleSearchMenu(e)
|
|
164
|
-
}
|
|
165
|
-
}}>
|
|
160
|
+
tabindex="1">
|
|
166
161
|
${icons.upload}
|
|
167
162
|
<span>Upload</span>
|
|
168
163
|
</a>`;
|
package/src/search-menu.js
CHANGED
|
@@ -30,26 +30,33 @@ class SearchMenu extends TrackedElement {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
firstUpdated() {
|
|
33
|
-
this.shadowRoot.addEventListener('
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
33
|
+
this.shadowRoot.addEventListener('keydown', e => this.handleKeyDownEvent(e));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
disconnectedCallback() {
|
|
37
|
+
// Clean up event listener when the element is removed
|
|
38
|
+
this.shadowRoot.removeEventListener('keydown', e => this.handleKeyDownEvent(e));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
handleKeyDownEvent(e) {
|
|
42
|
+
const searchTypes = this.shadowRoot.querySelectorAll('.search-menu-inner label input[type=radio]');
|
|
43
|
+
|
|
44
|
+
const length = searchTypes.length - 1;
|
|
45
|
+
if (!length) return;
|
|
46
|
+
|
|
47
|
+
const searchTypeHandler = (index) => {
|
|
48
|
+
e.preventDefault();
|
|
49
|
+
const searchType = searchTypes[index];
|
|
50
|
+
searchType.checked = true;
|
|
51
|
+
searchType.dispatchEvent(new Event('change'));
|
|
52
|
+
searchType.focus();
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
if (e.key === 'Home') {
|
|
56
|
+
searchTypeHandler(0);
|
|
57
|
+
} else if (e.key === 'End') {
|
|
58
|
+
searchTypeHandler(length);
|
|
59
|
+
}
|
|
53
60
|
}
|
|
54
61
|
|
|
55
62
|
selectSearchType(e) {
|