@ohhwells/bridge 0.1.113-next.297 → 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
@@ -9552,6 +9552,7 @@ function AiSectionOverlay({
9552
9552
  const sectionEl = inner ? movableUnit(inner) : null;
9553
9553
  const id = sectionEl ? instanceIdOf(sectionEl) || null : null;
9554
9554
  if (id === selectedIdRef.current) return;
9555
+ selectedIdRef.current = id;
9555
9556
  setSelectedId(id);
9556
9557
  if (options?.report !== false) report(sectionEl);
9557
9558
  },
@@ -9572,9 +9573,11 @@ function AiSectionOverlay({
9572
9573
  return sectionEl != null;
9573
9574
  },
9574
9575
  clear: () => {
9576
+ selectedIdRef.current = null;
9575
9577
  setSelectedId(null);
9576
9578
  report(null);
9577
- }
9579
+ },
9580
+ getSelectedId: () => selectedIdRef.current
9578
9581
  };
9579
9582
  return () => {
9580
9583
  apiRef.current = null;
@@ -9583,6 +9586,7 @@ function AiSectionOverlay({
9583
9586
  (0, import_react8.useEffect)(() => {
9584
9587
  const onMessage = (e) => {
9585
9588
  if (e.data?.type === "ow:ai-select" && e.data.sectionId === null) {
9589
+ selectedIdRef.current = null;
9586
9590
  setSelectedId(null);
9587
9591
  return;
9588
9592
  }
@@ -9633,6 +9637,7 @@ function AiSectionOverlay({
9633
9637
  if (reviewIdRef.current) return;
9634
9638
  if (document.querySelector("[data-ohw-editing]")) return;
9635
9639
  if (selectedIdRef.current) {
9640
+ selectedIdRef.current = null;
9636
9641
  setSelectedId(null);
9637
9642
  report(null);
9638
9643
  }
@@ -17877,12 +17882,18 @@ function OhhwellsBridge() {
17877
17882
  setSelectedMedia(null);
17878
17883
  const sectionEl = prev?.closest("[data-ohw-section]") ?? null;
17879
17884
  if (sectionEl) {
17880
- postToParentRef.current({
17881
- type: "ow:section-selected",
17882
- sectionId: sectionEl.dataset.ohwSection ?? null,
17883
- sectionLabel: sectionEl.dataset.ohwSectionLabel ?? titleCaseSectionId(sectionEl.dataset.ohwSection ?? ""),
17884
- key: null
17885
- });
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);
17886
17897
  }
17887
17898
  }, []);
17888
17899
  const clearMediaSelectionRef = (0, import_react17.useRef)(clearMediaSelection);