Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ export const TopBar = observer(
time: Date.now()
};

// If the clicked frame is not selected and this is not a multiselect operation,
// select it first to ensure we drag the correct frame
if (!editorEngine.frames.isSelected(frame.id) && !e.shiftKey) {
editorEngine.frames.select([frame], false);
}

// Get the currently selected frames after potential selection update
const selectedFrames = editorEngine.frames.selected.map(frameData => frameData.frame);
const framesToMove = selectedFrames.length > 0 ? selectedFrames : [frame];

Expand Down
18 changes: 17 additions & 1 deletion apps/web/client/src/components/store/editor/frames/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,27 @@ export class FramesManager {
}

select(frames: Frame[], multiselect = false) {
if (!multiselect) {
this.deselectAll();
// Without multiselect, always ensure frames are selected
for (const frame of frames) {
this.updateFrameSelection(frame.id, true);
}
} else {
// With multiselect, toggle individual frames
for (const frame of frames) {
this.updateFrameSelection(frame.id, !this.isSelected(frame.id));
}
}
this.notify();
}

ensureSelected(frames: Frame[], multiselect = false) {
if (!multiselect) {
this.deselectAll();
}
for (const frame of frames) {
this.updateFrameSelection(frame.id, !this.isSelected(frame.id));
this.updateFrameSelection(frame.id, true);
}
this.notify();
}
Expand Down
10 changes: 8 additions & 2 deletions packages/file-system/src/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@
*/

import type ZenFS from '@zenfs/core';
import { getFS } from './config';
import type { FileChangeEvent, FileEntry, FileInfo } from './types';
import {
type FileChangeEvent,
type FileChangeEvent,
type FileEntry,
type FileEntry,
type FileInfo,
type FileInfo,
} from './types';

export class FileSystem {
private fs: typeof ZenFS | null = null;
Expand Down
6 changes: 3 additions & 3 deletions packages/file-system/src/hooks/useDirectory.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState, useEffect } from 'react';
import { useFS } from './useFS';
import type { FileEntry } from '../types';
import { useEffect, useState } from 'react';

import { type FileEntry, type FileEntry } from '../types';

export function useDirectory(rootDir: string, path: string) {
const { fs, isInitializing, error: fsError } = useFS(rootDir);
Expand Down
3 changes: 2 additions & 1 deletion packages/file-system/src/hooks/useFS.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use client';

import { useState, useEffect } from 'react';
import { useEffect, useState } from 'react';

import { FileSystem } from '../fs';

export function useFS(rootDir: string) {
Expand Down
3 changes: 2 additions & 1 deletion packages/file-system/src/hooks/useFile.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useState, useEffect } from 'react';
import { useEffect, useState } from 'react';

import { useFS } from './useFS';

export function useFile(rootDir: string, path: string) {
Expand Down