@digitransit-component/digitransit-component-autosuggest 11.0.8 → 11.0.11
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/lib/index.cjs +2 -2
- package/lib/index.cjs.map +1 -1
- package/lib/index.development.cjs +18 -3
- package/lib/index.js +17 -2
- package/lib/index.js.map +1 -1
- package/package.json +5 -6
package/lib/index.js
CHANGED
|
@@ -12519,7 +12519,9 @@ function serialize(obj, prefix) {
|
|
|
12519
12519
|
}
|
|
12520
12520
|
|
|
12521
12521
|
/**
|
|
12522
|
-
* Return Promise for a url json get request
|
|
12522
|
+
* Return Promise for a url json get request. The promise rejects on network
|
|
12523
|
+
* errors, timeouts (10 s), HTTP 4xx/5xx responses (the error carries
|
|
12524
|
+
* `response.status`) and response bodies that are not valid JSON.
|
|
12523
12525
|
*
|
|
12524
12526
|
* @name getJson
|
|
12525
12527
|
* @param {String} url
|
|
@@ -12534,6 +12536,12 @@ function getJson(url, params) {
|
|
|
12534
12536
|
return axios.get(encodeURI(url) + (params ? (url.search(/\?/) === -1 ? '?' : '&') + serialize(params) : ''), {
|
|
12535
12537
|
timeout: 10000,
|
|
12536
12538
|
method: 'GET',
|
|
12539
|
+
// Reject non-JSON bodies (e.g. an HTML error page from a proxy)
|
|
12540
|
+
// instead of resolving with the raw string, which is axios's default.
|
|
12541
|
+
responseType: 'json',
|
|
12542
|
+
transitional: {
|
|
12543
|
+
silentJSONParsing: false
|
|
12544
|
+
},
|
|
12537
12545
|
headers: {
|
|
12538
12546
|
Accept: 'application/json'
|
|
12539
12547
|
}
|
|
@@ -16240,6 +16248,13 @@ function DTAutosuggest({
|
|
|
16240
16248
|
});
|
|
16241
16249
|
}
|
|
16242
16250
|
}, [state.renderMobile, isOpen]);
|
|
16251
|
+
|
|
16252
|
+
// Downshift keeps highlightedIndex when the suggestions change, and the
|
|
16253
|
+
// menu is hidden on mobile, so the highlighted item may not be shown.
|
|
16254
|
+
const activeItemHidden = isMobile || highlightedIndex >= state.suggestions.length;
|
|
16255
|
+
const getComboboxInputProps = props => getInputProps(_objectSpread(_objectSpread({}, props), activeItemHidden && {
|
|
16256
|
+
'aria-activedescendant': undefined
|
|
16257
|
+
}));
|
|
16243
16258
|
return /*#__PURE__*/jsxs(Fragment, {
|
|
16244
16259
|
children: [isMobile && /*#__PURE__*/jsx(MobileView, {
|
|
16245
16260
|
placeholder: t(placeholder, {
|
|
@@ -16287,7 +16302,7 @@ function DTAutosuggest({
|
|
|
16287
16302
|
})).concat(' ').concat(ariaLabelText),
|
|
16288
16303
|
id: id,
|
|
16289
16304
|
lng: lng,
|
|
16290
|
-
getInputProps:
|
|
16305
|
+
getInputProps: getComboboxInputProps,
|
|
16291
16306
|
getLabelProps: getLabelProps,
|
|
16292
16307
|
selectItem: selectItem,
|
|
16293
16308
|
value: state.value,
|