@ohhwells/bridge 0.1.117-next.328 → 0.1.117-next.329

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/index.cjs CHANGED
@@ -15552,10 +15552,10 @@ function FloatingPanel({
15552
15552
  y: fittedY
15553
15553
  };
15554
15554
  (0, import_react14.useEffect)(() => {
15555
- if (!open) {
15556
- setLiveScroll(parentScroll);
15557
- return;
15558
- }
15555
+ setLiveScroll(parentScroll);
15556
+ }, [parentScroll]);
15557
+ (0, import_react14.useEffect)(() => {
15558
+ if (!open) return;
15559
15559
  const onParentScroll = (e) => {
15560
15560
  if (e.data?.type !== "ow:parent-scroll") return;
15561
15561
  const { iframeOffsetTop, headerH, canvasH, promptBarH = 0 } = e.data;
@@ -15563,7 +15563,18 @@ function FloatingPanel({
15563
15563
  };
15564
15564
  window.addEventListener("message", onParentScroll);
15565
15565
  return () => window.removeEventListener("message", onParentScroll);
15566
- }, [open, parentScroll]);
15566
+ }, [open]);
15567
+ const positionRef = (0, import_react14.useRef)(position);
15568
+ (0, import_react14.useLayoutEffect)(() => {
15569
+ if (!open) {
15570
+ positionRef.current = position;
15571
+ return;
15572
+ }
15573
+ if (position == null && positionRef.current != null) {
15574
+ homeRef.current = defaultFloatingPanelPosition(liveScroll ?? parentScroll);
15575
+ }
15576
+ positionRef.current = position;
15577
+ }, [open, position, liveScroll, parentScroll]);
15567
15578
  (0, import_react14.useLayoutEffect)(() => {
15568
15579
  if (!open || !panelRef.current) return;
15569
15580
  const el = panelRef.current;
@@ -21912,6 +21923,7 @@ function OhhwellsBridge() {
21912
21923
  if (id && panel.buttonId !== id) {
21913
21924
  captureButtonOrigin(anchor);
21914
21925
  setFloatingPanelPos(null);
21926
+ setParentScrollSnap(parentScrollRef.current);
21915
21927
  setFloatingPanel({
21916
21928
  ...panel,
21917
21929
  key: `button-style:${id}`,