Don't drag for ephemeral blocks (#1288)

This commit is contained in:
Evan Simkowitz 2024-11-14 10:16:08 -08:00 committed by GitHub
parent ced3d73111
commit eb00716e00
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 8 deletions

View File

@ -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 (
<div
className="block-frame-default-header"
ref={dragHandleRef}
onContextMenu={onContextMenu}
draggable={!(preview || magnified || ephemeral)}
>
<div className="block-frame-default-header" ref={dragHandleRef} onContextMenu={onContextMenu}>
{preIconButtonElem}
<div className="block-frame-default-header-iconview">
{viewIconElem}

View File

@ -219,16 +219,19 @@ const DisplayNode = ({ layoutModel, node }: DisplayNodeProps) => {
const previewRef = useRef<HTMLDivElement>(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);