@constructor-io/constructorio-ui-autocomplete 1.25.4 → 1.25.5

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.
@@ -60,12 +60,26 @@ const useCioAutocomplete = (options) => {
60
60
  openMenu,
61
61
  closeMenu,
62
62
  getItemProps: (item) => {
63
- var _a;
63
+ var _a, _b;
64
64
  const { index, sectionId } = (0, helpers_1.getItemPosition)({ item, items });
65
65
  const sectionItemTestId = `cio-item-${sectionId === null || sectionId === void 0 ? void 0 : sectionId.replace(' ', '')}`;
66
- return Object.assign(Object.assign({}, getItemPropsDownShift({ item, index })), {
66
+ // Products always have links, Search Suggestions with getSearchResultsUrl have links
67
+ const hasLink = ((_a = item.data) === null || _a === void 0 ? void 0 : _a.url) || (item.section === 'Search Suggestions' && getSearchResultsUrl) || false;
68
+ const nonInteractiveItemsProps = {
69
+ tabIndex: 0,
70
+ onKeyDown: (event) => {
71
+ const { code, key } = event;
72
+ const isEnter = code === 'Enter' || key === 'Enter';
73
+ if (isEnter) {
74
+ event.preventDefault();
75
+ // Trigger default click behavior
76
+ getItemPropsDownShift({ item, index }).onClick(event);
77
+ }
78
+ },
79
+ };
80
+ return Object.assign(Object.assign(Object.assign({}, getItemPropsDownShift({ item, index })), {
67
81
  // @deprecated `sectionItemTestId` will be removed as a className in the next major version
68
- className: `cio-item ${sectionItemTestId}`, 'data-testid': sectionItemTestId, 'data-cnstrc-item-section': item.section, 'data-cnstrc-item-group': item.groupId, 'data-cnstrc-item-name': item.value, 'data-cnstrc-item-id': (_a = item.data) === null || _a === void 0 ? void 0 : _a.id });
82
+ className: `cio-item ${sectionItemTestId}`, 'data-testid': sectionItemTestId, 'data-cnstrc-item-section': item.section, 'data-cnstrc-item-group': item.groupId, 'data-cnstrc-item-name': item.value, 'data-cnstrc-item-id': (_b = item.data) === null || _b === void 0 ? void 0 : _b.id }), (hasLink ? {} : nonInteractiveItemsProps));
69
83
  },
70
84
  getInputProps: () => (Object.assign(Object.assign({}, getInputProps({
71
85
  onChange: (e) => {
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = '1.25.4';
3
+ exports.default = '1.25.5';
@@ -66,6 +66,20 @@ const useCioAutocomplete = (options) => {
66
66
  getItemProps: (item) => {
67
67
  const { index, sectionId } = getItemPosition({ item, items });
68
68
  const sectionItemTestId = `cio-item-${sectionId?.replace(' ', '')}`;
69
+ // Products always have links, Search Suggestions with getSearchResultsUrl have links
70
+ const hasLink = item.data?.url || (item.section === 'Search Suggestions' && getSearchResultsUrl) || false;
71
+ const nonInteractiveItemsProps = {
72
+ tabIndex: 0,
73
+ onKeyDown: (event) => {
74
+ const { code, key } = event;
75
+ const isEnter = code === 'Enter' || key === 'Enter';
76
+ if (isEnter) {
77
+ event.preventDefault();
78
+ // Trigger default click behavior
79
+ getItemPropsDownShift({ item, index }).onClick(event);
80
+ }
81
+ },
82
+ };
69
83
  return {
70
84
  ...getItemPropsDownShift({ item, index }),
71
85
  // @deprecated `sectionItemTestId` will be removed as a className in the next major version
@@ -75,6 +89,7 @@ const useCioAutocomplete = (options) => {
75
89
  'data-cnstrc-item-group': item.groupId,
76
90
  'data-cnstrc-item-name': item.value,
77
91
  'data-cnstrc-item-id': item.data?.id,
92
+ ...(hasLink ? {} : nonInteractiveItemsProps),
78
93
  };
79
94
  },
80
95
  getInputProps: () => ({
@@ -1 +1 @@
1
- export default '1.25.4';
1
+ export default '1.25.5';
@@ -1,2 +1,2 @@
1
- declare const _default: "1.25.4";
1
+ declare const _default: "1.25.5";
2
2
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructor-io/constructorio-ui-autocomplete",
3
- "version": "1.25.4",
3
+ "version": "1.25.5",
4
4
  "description": "Constructor.io Autocomplete UI library for web applications",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",