@react-aria/interactions 3.13.1 → 3.14.0

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/dist/module.js CHANGED
@@ -783,7 +783,7 @@ function $a1ea59d68270f0dd$export$f8168d8dd8fd66e6(props) {
783
783
  return {
784
784
  focusProps: {
785
785
  onFocus: !isDisabled && (onFocusProp || onFocusChange || onBlurProp) ? onFocus : undefined,
786
- onBlur: !isDisabled && (onBlurProp || onFocusChange) ? onBlur : null
786
+ onBlur: !isDisabled && (onBlurProp || onFocusChange) ? onBlur : undefined
787
787
  }
788
788
  };
789
789
  }
@@ -1192,10 +1192,8 @@ function $e0b6e0b68ec7f50f$export$872b660ac5a1ff98(props) {
1192
1192
  // Use pointer events if available. Otherwise, fall back to mouse and touch events.
1193
1193
  if (typeof PointerEvent !== "undefined") {
1194
1194
  let onPointerUp = (e)=>{
1195
- if (state.isPointerDown && state.onInteractOutside && $e0b6e0b68ec7f50f$var$isValidEvent(e, ref)) {
1196
- state.isPointerDown = false;
1197
- state.onInteractOutside(e);
1198
- }
1195
+ if (state.isPointerDown && state.onInteractOutside && $e0b6e0b68ec7f50f$var$isValidEvent(e, ref)) state.onInteractOutside(e);
1196
+ state.isPointerDown = false;
1199
1197
  };
1200
1198
  // changing these to capture phase fixed combobox
1201
1199
  document.addEventListener("pointerdown", onPointerDown, true);
@@ -1207,17 +1205,13 @@ function $e0b6e0b68ec7f50f$export$872b660ac5a1ff98(props) {
1207
1205
  } else {
1208
1206
  let onMouseUp = (e)=>{
1209
1207
  if (state.ignoreEmulatedMouseEvents) state.ignoreEmulatedMouseEvents = false;
1210
- else if (state.isPointerDown && state.onInteractOutside && $e0b6e0b68ec7f50f$var$isValidEvent(e, ref)) {
1211
- state.isPointerDown = false;
1212
- state.onInteractOutside(e);
1213
- }
1208
+ else if (state.isPointerDown && state.onInteractOutside && $e0b6e0b68ec7f50f$var$isValidEvent(e, ref)) state.onInteractOutside(e);
1209
+ state.isPointerDown = false;
1214
1210
  };
1215
1211
  let onTouchEnd = (e)=>{
1216
1212
  state.ignoreEmulatedMouseEvents = true;
1217
- if (state.onInteractOutside && state.isPointerDown && $e0b6e0b68ec7f50f$var$isValidEvent(e, ref)) {
1218
- state.isPointerDown = false;
1219
- state.onInteractOutside(e);
1220
- }
1213
+ if (state.onInteractOutside && state.isPointerDown && $e0b6e0b68ec7f50f$var$isValidEvent(e, ref)) state.onInteractOutside(e);
1214
+ state.isPointerDown = false;
1221
1215
  };
1222
1216
  document.addEventListener("mousedown", onPointerDown, true);
1223
1217
  document.addEventListener("mouseup", onMouseUp, true);
@@ -1238,10 +1232,12 @@ function $e0b6e0b68ec7f50f$export$872b660ac5a1ff98(props) {
1238
1232
  }
1239
1233
  function $e0b6e0b68ec7f50f$var$isValidEvent(event, ref) {
1240
1234
  if (event.button > 0) return false;
1241
- // if the event target is no longer in the document
1242
1235
  if (event.target) {
1236
+ // if the event target is no longer in the document, ignore
1243
1237
  const ownerDocument = event.target.ownerDocument;
1244
1238
  if (!ownerDocument || !ownerDocument.documentElement.contains(event.target)) return false;
1239
+ // If the target is within a top layer element (e.g. toasts), ignore.
1240
+ if (event.target.closest("[data-react-aria-top-layer]")) return false;
1245
1241
  }
1246
1242
  return ref.current && !ref.current.contains(event.target);
1247
1243
  }