@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.js CHANGED
@@ -7531,7 +7531,7 @@ function isInferredFooterGroup(el) {
7531
7531
  return Array.from(el.querySelectorAll(":scope > [data-ohw-href-key]")).some(isNavigationItem);
7532
7532
  }
7533
7533
  function isNavigationContainer(el) {
7534
- return el.hasAttribute("data-ohw-nav-container") || isNavigationRoot(el) || isInferredFooterGroup(el);
7534
+ return el.hasAttribute("data-ohw-nav-container") || el.hasAttribute("data-ohw-footer-col") || isNavigationRoot(el) || isInferredFooterGroup(el);
7535
7535
  }
7536
7536
  function isPointOverNavigation(x, y) {
7537
7537
  const navRoot = document.querySelector("[data-ohw-nav-root]") ?? document.querySelector("nav");
@@ -8480,6 +8480,53 @@ function OhhwellsBridge() {
8480
8480
  movedColumnIndex = Math.max(0, Math.min(adjusted, nextOrder.length - 1));
8481
8481
  }
8482
8482
  clearFooterDragVisuals();
8483
+ const applySelectionAfterDrop = () => {
8484
+ if (!wasSelected) {
8485
+ deselectRef.current();
8486
+ return;
8487
+ }
8488
+ if (hrefKey) {
8489
+ const link = document.querySelector(
8490
+ `footer [data-ohw-href-key="${CSS.escape(hrefKey)}"]`
8491
+ );
8492
+ if (link && isNavigationItem(link)) {
8493
+ selectRef.current(link);
8494
+ return;
8495
+ }
8496
+ }
8497
+ if (movedColumnIndex !== null && nextOrder) {
8498
+ const colKeys = nextOrder[movedColumnIndex] ?? [];
8499
+ let column = null;
8500
+ for (const key of colKeys) {
8501
+ const link = document.querySelector(
8502
+ `footer [data-ohw-href-key="${CSS.escape(key)}"]`
8503
+ );
8504
+ if (link) {
8505
+ column = findFooterColumnForLink(link);
8506
+ if (column) break;
8507
+ }
8508
+ }
8509
+ if (!column) column = listFooterColumns()[movedColumnIndex] ?? null;
8510
+ if (column && isNavigationContainer(column)) {
8511
+ selectFrameRef.current(column);
8512
+ return;
8513
+ }
8514
+ }
8515
+ if (document.body.contains(draggedEl)) {
8516
+ if (isNavigationItem(draggedEl)) {
8517
+ selectRef.current(draggedEl);
8518
+ return;
8519
+ }
8520
+ if (isNavigationContainer(draggedEl)) {
8521
+ selectFrameRef.current(draggedEl);
8522
+ return;
8523
+ }
8524
+ }
8525
+ deselectRef.current();
8526
+ };
8527
+ if (!wasSelected) {
8528
+ deselectRef.current();
8529
+ }
8483
8530
  if (nextOrder) {
8484
8531
  const orderJson = JSON.stringify(nextOrder);
8485
8532
  editContentRef.current = {
@@ -8488,31 +8535,20 @@ function OhhwellsBridge() {
8488
8535
  };
8489
8536
  applyFooterOrder(nextOrder);
8490
8537
  document.querySelectorAll("footer [data-ohw-href-key]").forEach(disableNativeHrefDrag);
8538
+ postToParentRef.current({
8539
+ type: "ow:change",
8540
+ nodes: [{ key: FOOTER_ORDER_KEY, text: orderJson }]
8541
+ });
8491
8542
  requestAnimationFrame(() => {
8492
8543
  if (editContentRef.current[FOOTER_ORDER_KEY] === orderJson) {
8493
8544
  applyFooterOrder(nextOrder);
8494
8545
  document.querySelectorAll("footer [data-ohw-href-key]").forEach(disableNativeHrefDrag);
8495
8546
  }
8547
+ requestAnimationFrame(applySelectionAfterDrop);
8496
8548
  });
8497
- postToParentRef.current({
8498
- type: "ow:change",
8499
- nodes: [{ key: FOOTER_ORDER_KEY, text: orderJson }]
8500
- });
8501
- }
8502
- if (!wasSelected) {
8503
- deselectRef.current();
8504
8549
  return;
8505
8550
  }
8506
- const still = (hrefKey ? document.querySelector(
8507
- `footer [data-ohw-href-key="${CSS.escape(hrefKey)}"]`
8508
- ) : null) ?? (movedColumnIndex !== null ? listFooterColumns()[movedColumnIndex] ?? null : null) ?? (document.body.contains(draggedEl) ? draggedEl : null);
8509
- if (still && isNavigationItem(still)) {
8510
- selectRef.current(still);
8511
- } else if (still && isNavigationContainer(still)) {
8512
- selectFrameRef.current(still);
8513
- } else {
8514
- deselectRef.current();
8515
- }
8551
+ applySelectionAfterDrop();
8516
8552
  },
8517
8553
  [clearFooterDragVisuals]
8518
8554
  );