From a763c4e80cec6aef5219a8c9fcfa2ddccbc10b0a Mon Sep 17 00:00:00 2001
From: eleanor-park <eleanor_park@brown.edu>
Date: Wed, 24 Jul 2024 16:52:50 -0400
Subject: bug and render fixes

---
 src/client/views/LightboxView.tsx | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

(limited to 'src/client/views/LightboxView.tsx')

diff --git a/src/client/views/LightboxView.tsx b/src/client/views/LightboxView.tsx
index 4fcb7ec9c..b0d469674 100644
--- a/src/client/views/LightboxView.tsx
+++ b/src/client/views/LightboxView.tsx
@@ -12,7 +12,7 @@ import { emptyFunction } from '../../Utils';
 import { CreateLinkToActiveAudio, Doc, DocListCast, FieldResult, Opt } from '../../fields/Doc';
 import { Id } from '../../fields/FieldSymbols';
 import { InkTool } from '../../fields/InkField';
-import { Cast, NumCast, toList } from '../../fields/Types';
+import { Cast, DocCast, NumCast, toList } from '../../fields/Types';
 import { SnappingManager } from '../util/SnappingManager';
 import { Transform } from '../util/Transform';
 import { GestureOverlay } from './GestureOverlay';
@@ -43,13 +43,11 @@ export class LightboxView extends ObservableReactComponent<LightboxViewProps> {
      * @returns true if a DocumentView is descendant of the lightbox view
      */
     public static Contains(view?: DocumentView) {
-        return true;
-    }
-    // return (
-    // (view && LightboxView.Instance?._docView && (view.containerViewPath?.() ?? []).concat(view).includes(LightboxView.Instance?._docView)) ||
-    // view?.Document === AnnotationPalette.Instance.FreeformCanvas ||
-    // view?.Document.embedContainer === AnnotationPalette.Instance.DrawingCarousel
-    // ); } // prettier-ignore
+        return (
+            (view && LightboxView.Instance?._docView && (view.containerViewPath?.() ?? []).concat(view).includes(LightboxView.Instance?._docView)) ||
+            (view && LightboxView.Instance?._annoPaletteView?.Contains(view))
+        ); 
+    } // prettier-ignore
     public static LightboxDoc = () => LightboxView.Instance?._doc;
     // eslint-disable-next-line no-use-before-define
     static Instance: LightboxView;
@@ -69,6 +67,7 @@ export class LightboxView extends ObservableReactComponent<LightboxViewProps> {
     @observable private _docTarget: Opt<Doc> = undefined;
     @observable private _docView: Opt<DocumentView> = undefined;
     @observable private _showPalette: boolean = false;
+    private _annoPaletteView: AnnotationPalette | null = null;
 
     @computed get leftBorder() { return Math.min(this._props.PanelWidth / 4, this._props.maxBorder[0]); } // prettier-ignore
     @computed get topBorder()  { return Math.min(this._props.PanelHeight / 4, this._props.maxBorder[1]); } // prettier-ignore
@@ -114,7 +113,6 @@ export class LightboxView extends ObservableReactComponent<LightboxViewProps> {
             this._history = [];
             Doc.ActiveTool = InkTool.None;
             SnappingManager.SetExploreMode(false);
-            AnnotationPalette.Instance.displayPalette(false);
             this._showPalette = false;
         }
         DocumentView.DeselectAll();
@@ -217,8 +215,7 @@ export class LightboxView extends ObservableReactComponent<LightboxViewProps> {
     };
     togglePalette = () => {
         this._showPalette = !this._showPalette;
-        AnnotationPalette.Instance.displayPalette(this._showPalette);
-        if (this._showPalette === false) AnnotationPalette.Instance.resetPalette(true);
+        // if (this._showPalette === false) AnnotationPalette.Instance.resetPalette(true);
     };
     togglePen = () => {
         Doc.ActiveTool = Doc.ActiveTool === InkTool.Pen ? InkTool.None : InkTool.Pen;
@@ -324,6 +321,7 @@ export class LightboxView extends ObservableReactComponent<LightboxViewProps> {
                     </GestureOverlay>
                 </div>
 
+                {this._showPalette && <AnnotationPalette ref={r => (this._annoPaletteView = r)} Document={DocCast(Doc.UserDoc().myLightboxDrawings)} />}
                 {this.renderNavBtn(0, undefined, this._props.PanelHeight / 2 - 12.5, 'chevron-left', this._doc && this._history.length, this.previous)}
                 {this.renderNavBtn(
                     this._props.PanelWidth - Math.min(this._props.PanelWidth / 4, this._props.maxBorder[0]),
-- 
cgit v1.2.3-70-g09d2

