@ohhwells/bridge 0.1.113-next.296 → 0.1.113-next.299

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
@@ -778,6 +778,8 @@ function applyStylesToDom(store) {
778
778
  if (isNavbar) {
779
779
  const drawer = document.querySelector("[data-ohw-nav-drawer]");
780
780
  if (drawer && !sections.includes(drawer)) sections.push(drawer);
781
+ const header = document.querySelector("[data-ohw-nav-root]");
782
+ if (header && !sections.includes(header)) sections.push(header);
781
783
  }
782
784
  for (const marker of Array.from(sections)) {
783
785
  const isDrawerMarker = isNavbar && marker.hasAttribute("data-ohw-nav-drawer");
@@ -9550,6 +9552,7 @@ function AiSectionOverlay({
9550
9552
  const sectionEl = inner ? movableUnit(inner) : null;
9551
9553
  const id = sectionEl ? instanceIdOf(sectionEl) || null : null;
9552
9554
  if (id === selectedIdRef.current) return;
9555
+ selectedIdRef.current = id;
9553
9556
  setSelectedId(id);
9554
9557
  if (options?.report !== false) report(sectionEl);
9555
9558
  },
@@ -9570,9 +9573,11 @@ function AiSectionOverlay({
9570
9573
  return sectionEl != null;
9571
9574
  },
9572
9575
  clear: () => {
9576
+ selectedIdRef.current = null;
9573
9577
  setSelectedId(null);
9574
9578
  report(null);
9575
- }
9579
+ },
9580
+ getSelectedId: () => selectedIdRef.current
9576
9581
  };
9577
9582
  return () => {
9578
9583
  apiRef.current = null;
@@ -9581,6 +9586,7 @@ function AiSectionOverlay({
9581
9586
  (0, import_react8.useEffect)(() => {
9582
9587
  const onMessage = (e) => {
9583
9588
  if (e.data?.type === "ow:ai-select" && e.data.sectionId === null) {
9589
+ selectedIdRef.current = null;
9584
9590
  setSelectedId(null);
9585
9591
  return;
9586
9592
  }
@@ -9631,6 +9637,7 @@ function AiSectionOverlay({
9631
9637
  if (reviewIdRef.current) return;
9632
9638
  if (document.querySelector("[data-ohw-editing]")) return;
9633
9639
  if (selectedIdRef.current) {
9640
+ selectedIdRef.current = null;
9634
9641
  setSelectedId(null);
9635
9642
  report(null);
9636
9643
  }
@@ -17875,12 +17882,18 @@ function OhhwellsBridge() {
17875
17882
  setSelectedMedia(null);
17876
17883
  const sectionEl = prev?.closest("[data-ohw-section]") ?? null;
17877
17884
  if (sectionEl) {
17878
- postToParentRef.current({
17879
- type: "ow:section-selected",
17880
- sectionId: sectionEl.dataset.ohwSection ?? null,
17881
- sectionLabel: sectionEl.dataset.ohwSectionLabel ?? titleCaseSectionId(sectionEl.dataset.ohwSection ?? ""),
17882
- key: null
17883
- });
17885
+ const sectionInstanceId = instanceIdOf(movableUnit(sectionEl)) || null;
17886
+ setTimeout(() => {
17887
+ if (!sectionInstanceId) return;
17888
+ if (aiSectionApiRef.current?.getSelectedId() !== sectionInstanceId) return;
17889
+ if (selectedMediaElRef.current) return;
17890
+ postToParentRef.current({
17891
+ type: "ow:section-selected",
17892
+ sectionId: sectionEl.dataset.ohwSection ?? null,
17893
+ sectionLabel: sectionEl.dataset.ohwSectionLabel ?? titleCaseSectionId(sectionEl.dataset.ohwSection ?? ""),
17894
+ key: null
17895
+ });
17896
+ }, 0);
17884
17897
  }
17885
17898
  }, []);
17886
17899
  const clearMediaSelectionRef = (0, import_react17.useRef)(clearMediaSelection);