From 442cb6eb721008191bccb4eae7fcf576aa460461 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Thu, 28 Sep 2023 00:45:58 -0400
Subject: fixed resetView to not apply to groups.

---
 .../collectionFreeForm/CollectionFreeFormView.tsx  | 35 ++++++++++++++--------
 1 file changed, 23 insertions(+), 12 deletions(-)

(limited to 'src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx')

diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index 9df96fabc..a64ccbb2c 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -1768,14 +1768,12 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection
 
         const appearance = ContextMenu.Instance.findByDescription('Appearance...');
         const appearanceItems = appearance && 'subitems' in appearance ? appearance.subitems : [];
-        appearanceItems.push({
-            description: 'Reset View',
-            event: () => {
-                this.props.Document[this.panXFieldKey] = this.props.Document[this.panYFieldKey] = 0;
-                this.props.Document[this.scaleFieldKey] = 1;
-            },
-            icon: 'compress-arrows-alt',
-        });
+        !this.props.Document._isGroup &&
+            appearanceItems.push({
+                description: 'Reset View',
+                event: () => CollectionFreeFormView.ResetView(this),
+                icon: 'compress-arrows-alt',
+            });
         !Doc.noviceMode &&
             appearanceItems.push({
                 description: 'Toggle auto arrange',
@@ -2099,6 +2097,22 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection
             </div>
         );
     }
+    /// resetView restores a freeform collection to unit scale and centered at (0,0)  UNLESS
+    //  the view is a group, in which case this does nothing (since Groups calculate their own scale and center)
+    static ResetView(view?: CollectionFreeFormView) {
+        if (view) {
+            if (view.props.Document._isGroup) return;
+            view.props.Document[view.panXFieldKey] = view.props.Document[view.panYFieldKey] = 0;
+            view.props.Document[view.scaleFieldKey] = 1;
+        } else {
+            SelectionManager.Docs()
+                .filter(doc => !doc._isGroup)
+                .forEach(doc => {
+                    doc._freeform_panX = doc._freeform_panY = 0;
+                    doc._freeform_scale = 1;
+                });
+        }
+    }
 }
 
 interface CollectionFreeFormOverlayViewProps {
@@ -2345,8 +2359,5 @@ ScriptingGlobals.add(function sendToBack(doc: Doc) {
     SelectionManager.Views().forEach(view => view.props.CollectionFreeFormDocumentView?.().props.CollectionFreeFormView.bringToFront(view.rootDoc, true));
 });
 ScriptingGlobals.add(function resetView() {
-    SelectionManager.Docs().forEach(doc => {
-        doc._freeform_panX = doc._freeform_panY = 0;
-        doc._freeform_scale = 1;
-    });
+    CollectionFreeFormView.ResetView();
 });
-- 
cgit v1.2.3-70-g09d2

