@ohhwells/bridge 0.1.38-next.70 → 0.1.38-next.71

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
@@ -7593,7 +7593,7 @@ function isInferredFooterGroup(el) {
7593
7593
  return Array.from(el.querySelectorAll(":scope > [data-ohw-href-key]")).some(isNavigationItem);
7594
7594
  }
7595
7595
  function isNavigationContainer(el) {
7596
- return el.hasAttribute("data-ohw-nav-container") || isNavigationRoot(el) || isInferredFooterGroup(el);
7596
+ return el.hasAttribute("data-ohw-nav-container") || el.hasAttribute("data-ohw-footer-col") || isNavigationRoot(el) || isInferredFooterGroup(el);
7597
7597
  }
7598
7598
  function isPointOverNavigation(x, y) {
7599
7599
  const navRoot = document.querySelector("[data-ohw-nav-root]") ?? document.querySelector("nav");
@@ -8542,6 +8542,53 @@ function OhhwellsBridge() {
8542
8542
  movedColumnIndex = Math.max(0, Math.min(adjusted, nextOrder.length - 1));
8543
8543
  }
8544
8544
  clearFooterDragVisuals();
8545
+ const applySelectionAfterDrop = () => {
8546
+ if (!wasSelected) {
8547
+ deselectRef.current();
8548
+ return;
8549
+ }
8550
+ if (hrefKey) {
8551
+ const link = document.querySelector(
8552
+ `footer [data-ohw-href-key="${CSS.escape(hrefKey)}"]`
8553
+ );
8554
+ if (link && isNavigationItem(link)) {
8555
+ selectRef.current(link);
8556
+ return;
8557
+ }
8558
+ }
8559
+ if (movedColumnIndex !== null && nextOrder) {
8560
+ const colKeys = nextOrder[movedColumnIndex] ?? [];
8561
+ let column = null;
8562
+ for (const key of colKeys) {
8563
+ const link = document.querySelector(
8564
+ `footer [data-ohw-href-key="${CSS.escape(key)}"]`
8565
+ );
8566
+ if (link) {
8567
+ column = findFooterColumnForLink(link);
8568
+ if (column) break;
8569
+ }
8570
+ }
8571
+ if (!column) column = listFooterColumns()[movedColumnIndex] ?? null;
8572
+ if (column && isNavigationContainer(column)) {
8573
+ selectFrameRef.current(column);
8574
+ return;
8575
+ }
8576
+ }
8577
+ if (document.body.contains(draggedEl)) {
8578
+ if (isNavigationItem(draggedEl)) {
8579
+ selectRef.current(draggedEl);
8580
+ return;
8581
+ }
8582
+ if (isNavigationContainer(draggedEl)) {
8583
+ selectFrameRef.current(draggedEl);
8584
+ return;
8585
+ }
8586
+ }
8587
+ deselectRef.current();
8588
+ };
8589
+ if (!wasSelected) {
8590
+ deselectRef.current();
8591
+ }
8545
8592
  if (nextOrder) {
8546
8593
  const orderJson = JSON.stringify(nextOrder);
8547
8594
  editContentRef.current = {
@@ -8550,31 +8597,20 @@ function OhhwellsBridge() {
8550
8597
  };
8551
8598
  applyFooterOrder(nextOrder);
8552
8599
  document.querySelectorAll("footer [data-ohw-href-key]").forEach(disableNativeHrefDrag);
8600
+ postToParentRef.current({
8601
+ type: "ow:change",
8602
+ nodes: [{ key: FOOTER_ORDER_KEY, text: orderJson }]
8603
+ });
8553
8604
  requestAnimationFrame(() => {
8554
8605
  if (editContentRef.current[FOOTER_ORDER_KEY] === orderJson) {
8555
8606
  applyFooterOrder(nextOrder);
8556
8607
  document.querySelectorAll("footer [data-ohw-href-key]").forEach(disableNativeHrefDrag);
8557
8608
  }
8609
+ requestAnimationFrame(applySelectionAfterDrop);
8558
8610
  });
8559
- postToParentRef.current({
8560
- type: "ow:change",
8561
- nodes: [{ key: FOOTER_ORDER_KEY, text: orderJson }]
8562
- });
8563
- }
8564
- if (!wasSelected) {
8565
- deselectRef.current();
8566
8611
  return;
8567
8612
  }
8568
- const still = (hrefKey ? document.querySelector(
8569
- `footer [data-ohw-href-key="${CSS.escape(hrefKey)}"]`
8570
- ) : null) ?? (movedColumnIndex !== null ? listFooterColumns()[movedColumnIndex] ?? null : null) ?? (document.body.contains(draggedEl) ? draggedEl : null);
8571
- if (still && isNavigationItem(still)) {
8572
- selectRef.current(still);
8573
- } else if (still && isNavigationContainer(still)) {
8574
- selectFrameRef.current(still);
8575
- } else {
8576
- deselectRef.current();
8577
- }
8613
+ applySelectionAfterDrop();
8578
8614
  },
8579
8615
  [clearFooterDragVisuals]
8580
8616
  );