Skip to content

Don't drag for ephemeral blocks #1288

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions frontend/app/block/blockframe.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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}
Expand Down
5 changes: 4 additions & 1 deletion frontend/layout/lib/TileLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading