@ethlete/core 5.0.0-next.24 → 5.0.0-next.25

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
@@ -1,5 +1,11 @@
1
1
  # @ethlete/core
2
2
 
3
+ ## 5.0.0-next.25
4
+
5
+ ### Patch Changes
6
+
7
+ - [#3017](https://github.com/ethlete-io/ethdk/pull/3017) [`83853d6`](https://github.com/ethlete-io/ethdk/commit/83853d6138bc7d0a481b5b982c2a7137b9cc65e6) Thanks [@github-actions](https://github.com/apps/github-actions)! - Overlay: anchored overlays with `autoCloseIfReferenceHidden` now close instantly when their anchor is removed, instead of jumping to the viewport corner and animating out from there.
8
+
3
9
  ## 5.0.0-next.24
4
10
 
5
11
  ### Minor Changes
@@ -4633,9 +4633,24 @@ const createAnchoredPositionCleanup = (strategy, paneElement, overlayRef, render
4633
4633
  strategy: 'absolute',
4634
4634
  middleware,
4635
4635
  }).then(({ x, y, placement, middlewareData }) => {
4636
+ // A detached reference reports a zeroed rect, so floating-ui positions the pane at the
4637
+ // viewport's top-left. Tear the overlay down (without animating from that bogus position)
4638
+ // before applying the transform when auto-close is on, and otherwise leave the pane where it
4639
+ // last was rather than snapping it to the corner.
4640
+ if (middlewareData.hide?.referenceHidden) {
4641
+ if (strategy.autoCloseIfReferenceHidden) {
4642
+ overlayRef.close(undefined, 'reference-detached');
4643
+ return;
4644
+ }
4645
+ if (strategy.autoHide) {
4646
+ renderer.setStyle(paneElement, { visibility: 'hidden' });
4647
+ }
4648
+ return;
4649
+ }
4636
4650
  renderer.setStyle(paneElement, {
4637
4651
  transform: `translate3d(${x}px, ${y}px, 0)`,
4638
4652
  width: mirrorWidthElement ? `${mirrorWidthElement.offsetWidth}px` : null,
4653
+ visibility: null,
4639
4654
  });
4640
4655
  // exposed so animations can compose their transforms with the anchored position
4641
4656
  renderer.setCssProperties(paneElement, {
@@ -4646,19 +4661,6 @@ const createAnchoredPositionCleanup = (strategy, paneElement, overlayRef, render
4646
4661
  if (arrowElement && middlewareData.arrow) {
4647
4662
  renderer.setCssProperty(arrowElement, '--et-floating-arrow-translate', `translate3d(${middlewareData.arrow.x ?? 0}px, ${middlewareData.arrow.y ?? 0}px, 0)`);
4648
4663
  }
4649
- if (middlewareData.hide?.referenceHidden) {
4650
- if (strategy.autoCloseIfReferenceHidden) {
4651
- overlayRef.close(undefined, 'api');
4652
- return;
4653
- }
4654
- renderer.setStyle(paneElement, {
4655
- visibility: strategy.autoHide ? 'hidden' : null,
4656
- });
4657
- return;
4658
- }
4659
- renderer.setStyle(paneElement, {
4660
- visibility: null,
4661
- });
4662
4664
  });
4663
4665
  });
4664
4666
  return () => {
@@ -4913,7 +4915,9 @@ const [provideOverlayRuntime, injectOverlayRuntime] = createRootProvider(() => {
4913
4915
  }
4914
4916
  const lifecycle = getAnimatedLifecycle(componentRef);
4915
4917
  animationDebugLog(`runtime ${config.id}`, `close requested (source "${closeEvent.source}", lifecycle state "${lifecycle?.state$.value ?? 'none'}", delegate ${config.animationDelegate?.leave ? 'yes' : 'no'})`);
4916
- if (!lifecycle) {
4918
+ // The reference element is gone — there is nothing left to animate away from, so tear the
4919
+ // overlay down synchronously instead of playing a leave transition from a stale position.
4920
+ if (!lifecycle || closeEvent.source === 'reference-detached') {
4917
4921
  destroyMountedOverlay(closeEvent);
4918
4922
  return;
4919
4923
  }