@homecode/ui 5.7.0 → 5.7.1

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.
@@ -30,6 +30,7 @@ function Select2(props) {
30
30
  const contentRef = useRef(null);
31
31
  const scrollInnerRef = useRef(null);
32
32
  const pointerPressedInside = useRef(false);
33
+ const pressStartedInside = useRef(false);
33
34
  const pointerPressTimer = useRef(0);
34
35
  const blurTimer = useRef(0);
35
36
  const [labelClipPath, setLabelClipPath] = useState('');
@@ -161,19 +162,39 @@ function Select2(props) {
161
162
  else
162
163
  open();
163
164
  };
165
+ const markPressInside = (isInside) => {
166
+ window.clearTimeout(pointerPressTimer.current);
167
+ pointerPressedInside.current = isInside;
168
+ pointerPressTimer.current = window.setTimeout(() => (pointerPressedInside.current = false), POINTER_PRESS_TTL);
169
+ };
164
170
  useEvent({
165
171
  event: 'pointerdown',
166
172
  isCapture: true,
167
173
  callback: e => {
168
- window.clearTimeout(pointerPressTimer.current);
169
- pointerPressedInside.current = isInsideSelect(e.target);
170
- pointerPressTimer.current = window.setTimeout(() => (pointerPressedInside.current = false), POINTER_PRESS_TTL);
174
+ pressStartedInside.current = isInsideSelect(e.target);
175
+ markPressInside(pressStartedInside.current);
176
+ },
177
+ });
178
+ useEvent({
179
+ event: 'pointerup',
180
+ isCapture: true,
181
+ callback: () => {
182
+ // The release can land on the portalled popup that mounted under the
183
+ // cursor mid-gesture, so the up-target is not a reliable inside signal.
184
+ if (pressStartedInside.current)
185
+ markPressInside(true);
186
+ pressStartedInside.current = false;
171
187
  },
172
188
  });
173
189
  useEvent({
174
190
  event: 'click',
175
191
  isActive: isOpen,
176
192
  callback: e => {
193
+ // The click concluding a press that started inside must not count as an
194
+ // outside click: the portalled popup can mount under the cursor, which
195
+ // retargets the click to a common ancestor outside the select.
196
+ if (pointerPressedInside.current)
197
+ return;
177
198
  if (!isInsideSelect(e.target))
178
199
  close();
179
200
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homecode/ui",
3
- "version": "5.7.0",
3
+ "version": "5.7.1",
4
4
  "description": "React UI components library",
5
5
  "scripts": {
6
6
  "tests": "jest",