@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/main.js CHANGED
@@ -807,7 +807,7 @@ function $5cb73d0ce355b0dc$export$f8168d8dd8fd66e6(props) {
807
807
  return {
808
808
  focusProps: {
809
809
  onFocus: !isDisabled && (onFocusProp || onFocusChange || onBlurProp) ? onFocus : undefined,
810
- onBlur: !isDisabled && (onBlurProp || onFocusChange) ? onBlur : null
810
+ onBlur: !isDisabled && (onBlurProp || onFocusChange) ? onBlur : undefined
811
811
  }
812
812
  };
813
813
  }
@@ -1216,10 +1216,8 @@ function $edcfa848c42f94f4$export$872b660ac5a1ff98(props) {
1216
1216
  // Use pointer events if available. Otherwise, fall back to mouse and touch events.
1217
1217
  if (typeof PointerEvent !== "undefined") {
1218
1218
  let onPointerUp = (e)=>{
1219
- if (state.isPointerDown && state.onInteractOutside && $edcfa848c42f94f4$var$isValidEvent(e, ref)) {
1220
- state.isPointerDown = false;
1221
- state.onInteractOutside(e);
1222
- }
1219
+ if (state.isPointerDown && state.onInteractOutside && $edcfa848c42f94f4$var$isValidEvent(e, ref)) state.onInteractOutside(e);
1220
+ state.isPointerDown = false;
1223
1221
  };
1224
1222
  // changing these to capture phase fixed combobox
1225
1223
  document.addEventListener("pointerdown", onPointerDown, true);
@@ -1231,17 +1229,13 @@ function $edcfa848c42f94f4$export$872b660ac5a1ff98(props) {
1231
1229
  } else {
1232
1230
  let onMouseUp = (e)=>{
1233
1231
  if (state.ignoreEmulatedMouseEvents) state.ignoreEmulatedMouseEvents = false;
1234
- else if (state.isPointerDown && state.onInteractOutside && $edcfa848c42f94f4$var$isValidEvent(e, ref)) {
1235
- state.isPointerDown = false;
1236
- state.onInteractOutside(e);
1237
- }
1232
+ else if (state.isPointerDown && state.onInteractOutside && $edcfa848c42f94f4$var$isValidEvent(e, ref)) state.onInteractOutside(e);
1233
+ state.isPointerDown = false;
1238
1234
  };
1239
1235
  let onTouchEnd = (e)=>{
1240
1236
  state.ignoreEmulatedMouseEvents = true;
1241
- if (state.onInteractOutside && state.isPointerDown && $edcfa848c42f94f4$var$isValidEvent(e, ref)) {
1242
- state.isPointerDown = false;
1243
- state.onInteractOutside(e);
1244
- }
1237
+ if (state.onInteractOutside && state.isPointerDown && $edcfa848c42f94f4$var$isValidEvent(e, ref)) state.onInteractOutside(e);
1238
+ state.isPointerDown = false;
1245
1239
  };
1246
1240
  document.addEventListener("mousedown", onPointerDown, true);
1247
1241
  document.addEventListener("mouseup", onMouseUp, true);
@@ -1262,10 +1256,12 @@ function $edcfa848c42f94f4$export$872b660ac5a1ff98(props) {
1262
1256
  }
1263
1257
  function $edcfa848c42f94f4$var$isValidEvent(event, ref) {
1264
1258
  if (event.button > 0) return false;
1265
- // if the event target is no longer in the document
1266
1259
  if (event.target) {
1260
+ // if the event target is no longer in the document, ignore
1267
1261
  const ownerDocument = event.target.ownerDocument;
1268
1262
  if (!ownerDocument || !ownerDocument.documentElement.contains(event.target)) return false;
1263
+ // If the target is within a top layer element (e.g. toasts), ignore.
1264
+ if (event.target.closest("[data-react-aria-top-layer]")) return false;
1269
1265
  }
1270
1266
  return ref.current && !ref.current.contains(event.target);
1271
1267
  }