@ticketboothapp/booking 1.2.42 → 1.2.43

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ticketboothapp/booking",
3
- "version": "1.2.42",
3
+ "version": "1.2.43",
4
4
  "private": false,
5
5
  "sideEffects": [
6
6
  "**/*.css",
@@ -1405,52 +1405,51 @@ export function BookingFlow({
1405
1405
  };
1406
1406
  }, [showTooltip]);
1407
1407
 
1408
- // Detect when itinerary box becomes sticky
1409
- // In viavia the scroll usually happens inside the dialog content div, not window.
1410
- // On full-page partner layouts, we instead listen to window scroll (useWindowScroll = true).
1408
+ // Detect when itinerary box becomes sticky.
1409
+ // Use a viewport IntersectionObserver sentinel so host-specific scroll containers
1410
+ // (dashboard embeds, dialog content, etc.) don't need custom scroll wiring.
1411
1411
  useEffect(() => {
1412
1412
  const el = itineraryRef.current;
1413
1413
  if (!el) return;
1414
+ if (typeof window === 'undefined' || !('IntersectionObserver' in window)) return;
1415
+
1416
+ const topInset = Math.max(0, flowUi?.itineraryStickyTopOffsetPx ?? 0);
1417
+ const sentinel = document.createElement('div');
1418
+ sentinel.setAttribute('data-itinerary-sticky-sentinel', 'true');
1419
+ sentinel.style.height = '1px';
1420
+ sentinel.style.margin = '0';
1421
+ sentinel.style.padding = '0';
1422
+ sentinel.style.pointerEvents = 'none';
1423
+ el.parentElement?.insertBefore(sentinel, el);
1424
+
1425
+ const observer = new IntersectionObserver(
1426
+ ([entry]) => {
1427
+ const nextSticky = !entry.isIntersecting;
1428
+ if (nextSticky !== isItineraryStickyRef.current) {
1429
+ isItineraryStickyRef.current = nextSticky;
1430
+ setIsItinerarySticky(nextSticky);
1431
+ }
1432
+ },
1433
+ {
1434
+ root: null,
1435
+ rootMargin: `${-topInset}px 0px 0px 0px`,
1436
+ threshold: 0,
1437
+ },
1438
+ );
1414
1439
 
1415
- const findScrollParent = (node: HTMLElement): HTMLElement | null => {
1416
- let parent = node.parentElement;
1417
- while (parent) {
1418
- const { overflowY } = getComputedStyle(parent);
1419
- if (overflowY === 'auto' || overflowY === 'scroll' || overflowY === 'overlay') return parent;
1420
- parent = parent.parentElement;
1421
- }
1422
- return null;
1423
- };
1424
-
1425
- const scrollParent = !useWindowScroll ? findScrollParent(el) : null;
1426
-
1427
- const updateStickyState = () => {
1428
- if (!itineraryRef.current) return;
1429
-
1430
- const rect = itineraryRef.current.getBoundingClientRect();
1431
- const containerTop =
1432
- scrollParent && !useWindowScroll ? scrollParent.getBoundingClientRect().top : 0;
1433
- const topInset = Math.max(0, flowUi?.itineraryStickyTopOffsetPx ?? 0);
1434
- const nextSticky = rect.top <= containerTop + topInset + 1;
1435
- if (nextSticky !== isItineraryStickyRef.current) {
1436
- isItineraryStickyRef.current = nextSticky;
1437
- setIsItinerarySticky(nextSticky);
1438
- }
1440
+ observer.observe(sentinel);
1441
+ return () => {
1442
+ observer.disconnect();
1443
+ sentinel.remove();
1439
1444
  };
1445
+ }, [selectedDate, selectedAvailability, flowUi?.itineraryStickyTopOffsetPx]); // Re-check when itinerary changes or host top inset changes
1440
1446
 
1441
- // Listen to both potential emitters; some embeds scroll window while the flow sits in a nested container.
1442
- const targets: EventTarget[] = [];
1443
- if (scrollParent) targets.push(scrollParent);
1444
- if (typeof window !== 'undefined') targets.push(window);
1445
- if (targets.length > 0) {
1446
- targets.forEach((target) => target.addEventListener('scroll', updateStickyState, { passive: true }));
1447
- updateStickyState();
1448
- return () => {
1449
- targets.forEach((target) => target.removeEventListener('scroll', updateStickyState));
1450
- };
1451
- }
1452
- return undefined;
1453
- }, [selectedDate, selectedAvailability, useWindowScroll, flowUi?.itineraryStickyTopOffsetPx]); // Re-check when itinerary / scroll mode / host chrome changes
1447
+ // TEMP DEBUG: confirm sticky state transitions in host embeds.
1448
+ useEffect(() => {
1449
+ if (typeof window === 'undefined') return;
1450
+ // eslint-disable-next-line no-console
1451
+ console.log('[booking-flow] isItinerarySticky:', isItinerarySticky);
1452
+ }, [isItinerarySticky]);
1454
1453
 
1455
1454
  // Find the earliest availability date - memoize with a stable reference
1456
1455
  // Only recalculate if we don't have a cached value or if the new earliest is actually earlier