@spaced-out/ui-design-system 0.2.3 → 0.2.4

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/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [0.2.4](https://github.com/spaced-out/ui-design-system/compare/v0.2.3...v0.2.4) (2024-10-15)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * ♳ fixes an issue with typeahead when when events are controlled from trigger the menu toggles b/w open and close states ([#276](https://github.com/spaced-out/ui-design-system/issues/276)) ([230b754](https://github.com/spaced-out/ui-design-system/commit/230b754b1f69d30ea4770daf9ea9b9cf6af7f8b7))
11
+
5
12
  ### [0.2.3](https://github.com/spaced-out/ui-design-system/compare/v0.2.2...v0.2.3) (2024-10-10)
6
13
 
7
14
 
@@ -10,6 +10,7 @@ var _size = require("../../styles/variables/_size");
10
10
  var _space = require("../../styles/variables/_space");
11
11
  var _classify = require("../../utils/classify");
12
12
  var _clickAway = require("../../utils/click-away");
13
+ var _mergeRefs = require("../../utils/merge-refs");
13
14
  var _Menu = require("../Menu");
14
15
  var _SearchInput = require("../SearchInput");
15
16
  var _TypeaheadModule = _interopRequireDefault(require("./Typeahead.module.css"));
@@ -69,7 +70,8 @@ const Typeahead = /*#__PURE__*/React.forwardRef((_ref, ref) => {
69
70
  isOpen,
70
71
  onOpen,
71
72
  clickAway,
72
- boundaryRef
73
+ boundaryRef,
74
+ triggerRef
73
75
  } = _ref2;
74
76
  return /*#__PURE__*/React.createElement("div", {
75
77
  "data-testid": "Typeahead",
@@ -77,7 +79,7 @@ const Typeahead = /*#__PURE__*/React.forwardRef((_ref, ref) => {
77
79
  ref: boundaryRef
78
80
  }, /*#__PURE__*/React.createElement(_SearchInput.SearchInput, _extends({}, inputProps, {
79
81
  ref: ref,
80
- boxRef: refs.setReference,
82
+ boxRef: (0, _mergeRefs.mergeRefs)([refs.setReference, triggerRef]),
81
83
  size: size,
82
84
  placeholder: placeholder,
83
85
  value: typeaheadInputText,
@@ -89,14 +91,14 @@ const Typeahead = /*#__PURE__*/React.forwardRef((_ref, ref) => {
89
91
  e.stopPropagation();
90
92
  onSearch && onSearch(e);
91
93
  if (e.target.value.length >= menuOpenOffset) {
92
- onOpen();
94
+ !isOpen && onOpen();
93
95
  } else {
94
96
  clickAway();
95
97
  }
96
98
  },
97
99
  onFocus: _e => {
98
100
  if (typeaheadInputText.length >= menuOpenOffset) {
99
- onOpen();
101
+ !isOpen && onOpen();
100
102
  } else {
101
103
  clickAway();
102
104
  }
@@ -16,6 +16,7 @@ import {sizeFluid} from '../../styles/variables/_size';
16
16
  import {spaceNone, spaceXXSmall} from '../../styles/variables/_space';
17
17
  import {classify} from '../../utils/classify';
18
18
  import {type ClickAwayRefType, ClickAway} from '../../utils/click-away';
19
+ import {mergeRefs} from '../../utils/merge-refs';
19
20
  import type {InputProps} from '../Input';
20
21
  import type {MenuOption, MenuProps} from '../Menu';
21
22
  import {Menu} from '../Menu';
@@ -98,7 +99,7 @@ export const Typeahead: React$AbstractComponent<
98
99
 
99
100
  return (
100
101
  <ClickAway onChange={onMenuToggle} clickAwayRef={clickAwayRef}>
101
- {({isOpen, onOpen, clickAway, boundaryRef}) => (
102
+ {({isOpen, onOpen, clickAway, boundaryRef, triggerRef}) => (
102
103
  <div
103
104
  data-testid="Typeahead"
104
105
  className={classify(css.typeaheadContainer, classNames?.wrapper)}
@@ -107,7 +108,7 @@ export const Typeahead: React$AbstractComponent<
107
108
  <SearchInput
108
109
  {...inputProps}
109
110
  ref={ref}
110
- boxRef={refs.setReference}
111
+ boxRef={mergeRefs([refs.setReference, triggerRef])}
111
112
  size={size}
112
113
  placeholder={placeholder}
113
114
  value={typeaheadInputText}
@@ -117,14 +118,14 @@ export const Typeahead: React$AbstractComponent<
117
118
  e.stopPropagation();
118
119
  onSearch && onSearch(e);
119
120
  if (e.target.value.length >= menuOpenOffset) {
120
- onOpen();
121
+ !isOpen && onOpen();
121
122
  } else {
122
123
  clickAway();
123
124
  }
124
125
  }}
125
126
  onFocus={(_e) => {
126
127
  if (typeaheadInputText.length >= menuOpenOffset) {
127
- onOpen();
128
+ !isOpen && onOpen();
128
129
  } else {
129
130
  clickAway();
130
131
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spaced-out/ui-design-system",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "main": "index.js",
5
5
  "description": "Sense UI components library",
6
6
  "author": {