From b0408fa264fc8a017c87a17325600d8e458fe711 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Mon, 6 Jun 2022 01:32:36 -0400
Subject: fixed up overlayDocs a bit so that they can be removed.  made
 audioBox's appear in overlay when clicked from toolbar. add links to audio
 when navigating to doc in lightbox.

---
 src/client/views/nodes/AudioBox.tsx | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

(limited to 'src/client/views/nodes/AudioBox.tsx')

diff --git a/src/client/views/nodes/AudioBox.tsx b/src/client/views/nodes/AudioBox.tsx
index 9b92762a2..787ad939d 100644
--- a/src/client/views/nodes/AudioBox.tsx
+++ b/src/client/views/nodes/AudioBox.tsx
@@ -350,7 +350,14 @@ export class AudioBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProp
         Doc.GetProto(newDoc).recordingSource = this.dataDoc;
         Doc.GetProto(newDoc).recordingStart = ComputedField.MakeFunction(`self.recordingSource["${this.fieldKey}-recordingStart"]`);
         Doc.GetProto(newDoc).mediaState = ComputedField.MakeFunction("self.recordingSource.mediaState");
-        this.props.addDocument?.(newDoc);
+        const overlayDoc = Doc.UserDoc().myOverlayDocs as Doc;
+        if (DocListCast(overlayDoc[Doc.LayoutFieldKey(overlayDoc)]).includes(this.rootDoc)) {
+            newDoc.x = this.rootDoc.x;
+            newDoc.y = NumCast(this.rootDoc.y) + NumCast(this.rootDoc._height);
+            Doc.AddDocToList(overlayDoc, undefined, newDoc);
+        } else {
+            this.props.addDocument?.(newDoc);
+        }
         e.stopPropagation();
     }
 
-- 
cgit v1.2.3-70-g09d2

