aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2023-11-27 13:46:27 -0500
committerbobzel <zzzman@gmail.com>2023-11-27 13:46:27 -0500
commitac360607bee82f0fef769eada99dc0b3f85ae70a (patch)
tree25d145b1d9af0e3fd0d3741bbf68282ff56381b5
parenta1bd5f7bce9aa1e9cb0d1194789fc482472465bc (diff)
fixed dataView to not lose focus when typing 'enter' by fixing freeformdocumentview panelwidth() to
-rw-r--r--src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx4
-rw-r--r--src/client/views/nodes/CollectionFreeFormDocumentView.tsx10
-rw-r--r--src/fields/Doc.ts2
3 files changed, 8 insertions, 8 deletions
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index 2e66c9012..7f8bde9b4 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -1289,8 +1289,8 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection
const { z, zIndex } = childDoc;
const { backgroundColor, color } = contentFrameNumber === undefined ? { backgroundColor: undefined, color: undefined } : CollectionFreeFormDocumentView.getStringValues(childDoc, contentFrameNumber);
const { x, y, _width, _height, opacity, _rotation } =
- layoutFrameNumber === undefined
- ? { _width: Cast(childDocLayout._width, 'number'), _height: Cast(childDocLayout._height, 'number'), _rotation: Cast(childDocLayout._rotation, 'number'), x: childDoc.x, y: childDoc.y, opacity: this.props.childOpacity?.() }
+ layoutFrameNumber === undefined // -1 for width/height means width/height should be PanelWidth/PanelHeight (prevents collectionfreeformdocumentview width/height from getting out of synch with panelWIdth/Height which causes detailView to re-render and lose focus because HTMLtag scaling gets set to a bad intermediate value)
+ ? { _width: -1, _height: -1, _rotation: Cast(childDocLayout._rotation, 'number'), x: childDoc.x, y: childDoc.y, opacity: this.props.childOpacity?.() }
: CollectionFreeFormDocumentView.getValues(childDoc, layoutFrameNumber);
// prettier-ignore
const rotation = Cast(_rotation,'number',
diff --git a/src/client/views/nodes/CollectionFreeFormDocumentView.tsx b/src/client/views/nodes/CollectionFreeFormDocumentView.tsx
index 421d431b3..dd16ab71b 100644
--- a/src/client/views/nodes/CollectionFreeFormDocumentView.tsx
+++ b/src/client/views/nodes/CollectionFreeFormDocumentView.tsx
@@ -1,4 +1,4 @@
-import { action, computed, observable, trace } from 'mobx';
+import { action, computed, observable } from 'mobx';
import { observer } from 'mobx-react';
import { Doc, Opt } from '../../../fields/Doc';
import { List } from '../../../fields/List';
@@ -20,8 +20,8 @@ export interface CollectionFreeFormDocumentViewWrapperProps extends DocumentView
x: number;
y: number;
z: number;
- width: number;
- height: number;
+ width: number; // -1 means use PanelWidth which should be the same as the Document's width, but avoids the delay of waiting for the width prop to change in PanelWidth function
+ height: number; // -1 means use PanelHeight
zIndex?: number;
rotation?: number;
color?: string;
@@ -72,8 +72,8 @@ export class CollectionFreeFormDocumentViewWrapper extends DocComponent<Collecti
w_Transition = () => this.Transition; // prettier-ignore
w_DataTransition = () => this.DataTransition; // prettier-ignore
- PanelWidth = () => this.Width || this.props.PanelWidth?.(); // prettier-ignore
- PanelHeight = () => this.Height || this.props.PanelHeight?.(); // prettier-ignore
+ PanelWidth = () => this.Width > 0 ? this.Width : this.props.PanelWidth?.(); // prettier-ignore
+ PanelHeight = () => this.Height > 0 ? this.Height : this.props.PanelHeight?.(); // prettier-ignore
@action
componentDidUpdate() {
this.WrapperKeys.forEach(keys => ((this as any)[keys.upper] = (this.props as any)[keys.lower]));
diff --git a/src/fields/Doc.ts b/src/fields/Doc.ts
index 368aaa5db..e2746091e 100644
--- a/src/fields/Doc.ts
+++ b/src/fields/Doc.ts
@@ -1059,7 +1059,7 @@ export namespace Doc {
}
export function NativeHeight(doc?: Doc, dataDoc?: Doc, useHeight?: boolean) {
if (!doc) return 0;
- const nheight = (Doc.NativeWidth(doc, dataDoc, useHeight) * NumCast(doc._height)) / NumCast(doc._width);
+ const nheight = (Doc.NativeWidth(doc, dataDoc, useHeight) / NumCast(doc._width)) * NumCast(doc._height); // divide before multiply to avoid floating point errrorin case nativewidth = width
const dheight = NumCast((dataDoc || doc)[Doc.LayoutFieldKey(doc) + '_nativeHeight'], useHeight ? NumCast(doc._height) : 0);
return NumCast(doc._nativeHeight, nheight || dheight);
}