From 325aa35c4bd5f57240ead2ec5f22ea9c4f19d522 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Thu, 15 Aug 2024 23:16:09 -0400
Subject: fixed dropping on multi col/row collections with margins

---
 .../CollectionMultirowView.tsx                     | 31 ++++++++++++----------
 1 file changed, 17 insertions(+), 14 deletions(-)

(limited to 'src/client/views/collections/collectionMulticolumn/CollectionMultirowView.tsx')

diff --git a/src/client/views/collections/collectionMulticolumn/CollectionMultirowView.tsx b/src/client/views/collections/collectionMulticolumn/CollectionMultirowView.tsx
index 2833ff2f8..04b85e182 100644
--- a/src/client/views/collections/collectionMulticolumn/CollectionMultirowView.tsx
+++ b/src/client/views/collections/collectionMulticolumn/CollectionMultirowView.tsx
@@ -196,12 +196,12 @@ export class CollectionMultirowView extends CollectionSubView() {
     @undoBatch
     onInternalDrop = (e: Event, de: DragManager.DropEvent) => {
         let dropInd = -1;
-        if (de.complete.docDragData && this._mainCont) {
+        if (de.complete.docDragData && this._contRef.current) {
             let curInd = -1;
             de.complete.docDragData?.droppedDocuments.forEach(d => {
                 curInd = this.childDocs.indexOf(d);
             });
-            Array.from(this._mainCont.children).forEach((child, index) => {
+            Array.from(this._contRef.current.children).forEach((child, index) => {
                 const brect = child.getBoundingClientRect();
                 if (brect.y < de.y && brect.y + brect.height > de.y) {
                     if (curInd !== -1 && curInd === Math.floor(index / 2)) {
@@ -318,20 +318,23 @@ export class CollectionMultirowView extends CollectionSubView() {
         return collector;
     }
 
+    _contRef = React.createRef<HTMLDivElement>();
     render() {
         return (
-            <div
-                className="collectionMultirowView_contents"
-                style={{
-                    width: `calc(100% - ${2 * NumCast(this.Document._xMargin)}px)`,
-                    height: `calc(100% - ${2 * NumCast(this.Document._yMargin)}px)`,
-                    marginLeft: NumCast(this.Document._xMargin),
-                    marginRight: NumCast(this.Document._xMargin),
-                    marginTop: NumCast(this.Document._yMargin),
-                    marginBottom: NumCast(this.Document._yMargin),
-                }}
-                ref={this.createDashEventsTarget}>
-                {this.contents}
+            <div className="collectionMultirowView_drop" ref={this.createDashEventsTarget}>
+                <div
+                    ref={this._contRef}
+                    className="collectionMultirowView_contents"
+                    style={{
+                        width: `calc(100% - ${2 * NumCast(this.Document._xMargin)}px)`,
+                        height: `calc(100% - ${2 * NumCast(this.Document._yMargin)}px)`,
+                        marginLeft: NumCast(this.Document._xMargin),
+                        marginRight: NumCast(this.Document._xMargin),
+                        marginTop: NumCast(this.Document._yMargin),
+                        marginBottom: NumCast(this.Document._yMargin),
+                    }}>
+                    {this.contents}
+                </div>
             </div>
         );
     }
-- 
cgit v1.2.3-70-g09d2

