@financial-times/dotcom-ui-header 9.0.0-beta.2 → 9.0.0-beta.3
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": "@financial-times/dotcom-ui-header",
|
|
3
|
-
"version": "9.0.0-beta.
|
|
3
|
+
"version": "9.0.0-beta.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"browser": "browser.js",
|
|
6
6
|
"main": "component.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"author": "",
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@financial-times/dotcom-types-navigation": "^9.0.0-beta.
|
|
25
|
+
"@financial-times/dotcom-types-navigation": "^9.0.0-beta.3",
|
|
26
26
|
"n-topic-search": "^4.0.0",
|
|
27
27
|
"n-ui-foundations": "^9.0.0"
|
|
28
28
|
},
|
|
@@ -12,12 +12,14 @@ class CustomSuggestionList extends BaseRenderer {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
renderSuggestionChip = (term) => {
|
|
15
|
+
const WORD_LIMIT = 60
|
|
15
16
|
return `<a
|
|
16
17
|
data-trackable="link"
|
|
17
18
|
data-suggestion-id="${term}"
|
|
18
19
|
href="${this.enhancedSearchUrl}${term}"
|
|
19
20
|
class="n-topic-search__target enhanced-search__chip">
|
|
20
|
-
<span class="enhanced-search__chip-text">${term}
|
|
21
|
+
<span class="enhanced-search__chip-text">${term.substring(0, WORD_LIMIT)}
|
|
22
|
+
${term.length > WORD_LIMIT ? '...' : ''}</span>
|
|
21
23
|
</a>`
|
|
22
24
|
}
|
|
23
25
|
|
|
@@ -8,12 +8,20 @@ class EnhancedSearch extends TopicSearch {
|
|
|
8
8
|
listComponent: (...args) => new CustomSuggestionList(...args.concat(options?.enhancedSearchUrl))
|
|
9
9
|
})
|
|
10
10
|
|
|
11
|
+
this.updateEnhancedSearchAttributes(options)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
updateEnhancedSearchAttributes(options) {
|
|
11
15
|
const inputs = [
|
|
12
16
|
document.querySelector('#o-header-search-term-primary'),
|
|
13
17
|
document.querySelector('#o-header-search-term-sticky'),
|
|
14
18
|
document.querySelector('#o-header-drawer-search-term')
|
|
15
19
|
]
|
|
16
|
-
|
|
20
|
+
|
|
21
|
+
const form = inputs[0].parentElement
|
|
22
|
+
|
|
23
|
+
form.setAttribute('data-attribute-enhanced-search', 'true')
|
|
24
|
+
form.setAttribute('action', options?.enhancedSearchUrl ?? '/search')
|
|
17
25
|
inputs.forEach((input) =>
|
|
18
26
|
input.setAttribute('placeholder', 'Search the FT using questions, topics or article titles')
|
|
19
27
|
)
|