From eb00716e0066b5c383482f234c0dc0cae78d6221 Mon Sep 17 00:00:00 2001 From: Evan Simkowitz Date: Thu, 14 Nov 2024 10:16:08 -0800 Subject: [PATCH] Don't drag for ephemeral blocks (#1288) --- frontend/app/block/blockframe.tsx | 8 +------- frontend/layout/lib/TileLayout.tsx | 5 ++++- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/frontend/app/block/blockframe.tsx b/frontend/app/block/blockframe.tsx index 408997747..1ec668467 100644 --- a/frontend/app/block/blockframe.tsx +++ b/frontend/app/block/blockframe.tsx @@ -180,7 +180,6 @@ const BlockFrame_Header = ({ const preIconButton = util.useAtomValueSafe(viewModel?.preIconButton); let headerTextUnion = util.useAtomValueSafe(viewModel?.viewText); const magnified = jotai.useAtomValue(nodeModel.isMagnified); - const ephemeral = jotai.useAtomValue(nodeModel.isEphemeral); const manageConnection = util.useAtomValueSafe(viewModel?.manageConnection); const dragHandleRef = preview ? null : nodeModel.dragHandleRef; @@ -236,12 +235,7 @@ const BlockFrame_Header = ({ } return ( -
+
{preIconButtonElem}
{viewIconElem} diff --git a/frontend/layout/lib/TileLayout.tsx b/frontend/layout/lib/TileLayout.tsx index 7425f9707..f2a2d8dad 100644 --- a/frontend/layout/lib/TileLayout.tsx +++ b/frontend/layout/lib/TileLayout.tsx @@ -219,16 +219,19 @@ const DisplayNode = ({ layoutModel, node }: DisplayNodeProps) => { const previewRef = useRef(null); const addlProps = useAtomValue(nodeModel.additionalProps); const devicePixelRatio = useDevicePixelRatio(); + const isEphemeral = useAtomValue(nodeModel.isEphemeral); + const isMagnified = useAtomValue(nodeModel.isMagnified); const [{ isDragging }, drag, dragPreview] = useDrag( () => ({ type: dragItemType, + canDrag: () => !(isEphemeral || isMagnified), item: () => node, collect: (monitor) => ({ isDragging: monitor.isDragging(), }), }), - [node, addlProps] + [node, addlProps, isEphemeral, isMagnified] ); const [previewElementGeneration, setPreviewElementGeneration] = useState(0);