Skip to content

feat: Multi-Select for ObjectsList UI Panel - #8959

Open
ViktorVovk wants to merge 6 commits into
4ian:masterfrom
PlaytikaOSS:feat/scene-object-multiselect
Open

feat: Multi-Select for ObjectsList UI Panel #8959
ViktorVovk wants to merge 6 commits into
4ian:masterfrom
PlaytikaOSS:feat/scene-object-multiselect

Conversation

@ViktorVovk

@ViktorVovk ViktorVovk commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Multi-selection for objects and folders in the Objects panel

What

Adds multi-selection support to the Objects panel, letting users select, copy, cut, paste, duplicate, delete, and reorganize multiple objects and folders at once — including cross-scene and cross-global-objects actions.

Changes

Selection

  • Ctrl+click adds/removes individual items to the selection.
  • Shift+click extends the selection from the anchor using VS Code–style "multi-range" behavior: items outside the new range that were selected before the Shift press are preserved, not dropped.
  • Keyboard navigation (arrow keys) without Shift moves the cursor and updates the anchor; with Shift it extends the range from the existing anchor.
  • Selection is scoped to one section at a time (scene objects or global objects). Crossing the boundary is silently capped so the invariant is never violated.

Context menu on multi-selection
Shows a bulk action menu instead of the single-item menu:

  • Copy / Cut / Paste / Duplicate
  • Delete (with a single confirmation dialog listing the count)
  • Move to folder → submenu with all valid target folders (excludes the current parent if all selected items are already there, and excludes selected folders and their descendants)
  • Create new folder (moves the selection into a freshly created folder)
  • Set as global object (only shown when the entire selection consists of non-folder scene objects)

Keyboard shortcuts
Ctrl+C, Ctrl+X, Ctrl+V, Ctrl+D, Backspace/Delete, Ctrl+A, Escape all operate on the full selection. Ctrl+D duplicates each selected item right after itself in its parent folder, preserving per-parent insertion offsets when siblings share a folder. Cut serializes to an in-memory payload before prompting for deletion so that a cancelled cut never pollutes the clipboard.

Clipboard — copy/paste of folders
Folders are serialized recursively (structure + all child objects with their properties and behaviors). Pasting a folder restores the full subtree, generating unique names for any name collisions. Pasting a mix of objects and folders works correctly; pasting only empty folders does not fire the onObjectCreated hook.

Drag and drop
Multiple selected items can be dragged as a unit. The drop is blocked when the destination folder is itself part of the selection (C++ only guards descendants, not self). Dropping onto the global-objects section is blocked when the selection contains folders.

Properties panel
Shows "N objects selected" when more than one plain object is selected; shows "Folder selected. No properties to display." when only folders are selected.

Bug fixes included

  • onDelete shortcut no longer calls delete() on undefined when nothing is selected.
  • onPaste with no selection now respects the last-active section (scene vs global).
  • bulkDelete on empty-folder-only selections correctly triggers onObjectModified so unsaved-changes tracking fires.
  • Pasting multiple objects no longer auto-places stacked instances at the same canvas coordinates when newObjectInstanceSceneCoordinates is stale from a previous "add under cursor" flow.
  • "Move to folder" submenu no longer shows the current parent folder as a valid destination.
  • bulkMoveToFolder preserves the original selection order instead of reversing it.

Architecture

New file Responsibility
ObjectFolderOrObjectsClipboard.js Serialize / deserialize object+folder trees to/from the OS clipboard
ObjectFolderOrObjectsDuplicate.js In-place duplication without touching the clipboard
useBulkObjectOperations.js Copy, cut, paste, duplicate, delete, set-as-global, move-to-folder, build bulk menu
useObjectsSelection.js Selection state, section tracking, select-all, deselect-all
useTreeViewSelection.js Anchor-based Shift+click / Shift+arrow multi-range selection for TreeView

Selection utilities (getSelectionTopLevelNodes, getObjectsToDeleteFromSelection, removeEmptyFoldersFromSelection, enumerateAllChildrenInFolder) live in EnumerateObjectFolderOrObject.js, separate from clipboard concerns.

TreeView/index.js gained three exported types — FlattenedNode<Item>, SelectArgs<Item>, OnSelectFn<Item> — that eliminate the duplicated inline shapes across ItemData, getItemProps, and useTreeViewSelection.

Testing

  • ObjectFolderOrObjectsClipboard.spec.js — unit tests for serialization round-trips, nested-folder paste, duplicate-name resolution, backward compatibility with the single-item clipboard format, and in-place duplication.
  • ObjectFolderOrObjectSelection.spec.js — extended with multi-selection scenarios.
  • ObjectsList.stories.js — new WithMultiSelection story.

Viktor Vovk added 6 commits August 11, 2026 14:08
This commit introduces functionality for copying, pasting, and managing object and folder selections in the clipboard. It includes new utility functions for serializing and deserializing clipboard content, ensuring unique names for pasted items, and handling bulk operations like copy, cut, and delete. Additionally, it enhances the user interface with appropriate menu options for these operations.

Key changes:
- Implemented clipboard management for object and folder selections.
- Added functions to serialize and paste objects and folders.
- Updated UI components to integrate clipboard actions.
- Improved handling of nested folders during bulk operations.
…ditor

This commit enhances type safety by explicitly defining array types for various object collections across multiple files. It also includes minor formatting adjustments for improved readability and consistency in the codebase.

Key changes:
- Updated array declarations to use explicit types in EnumerateObjectFolderOrObject.js, ObjectFolderOrObjectsClipboard.js, and useBulkObjectOperations.js.
- Cleaned up formatting in index.js and useObjectsSelection.js for better clarity.
- Improved type definitions in TreeView components for better type checking.
This commit refines the clipboard management for object and folder operations, introducing a new utility for duplicating objects and improving the handling of selection contexts. It also updates type annotations for better clarity and consistency across the codebase.

Key changes:
- Added `duplicateObjectFolderOrObjects` utility for in-place duplication.
- Enhanced `getPasteMenuLabel` to provide localized labels based on clipboard content.
- Updated function signatures and type annotations for better type safety.
- Refactored object selection handling to use consistent naming conventions.
- Improved integration of clipboard actions within the UI components.
This commit enhances the clipboard functionality for object and folder operations, streamlining the code and improving type safety across several files. Key changes include:

- Updated `getPasteMenuLabel` for better localization handling.
- Refactored object selection logic for clarity and consistency.
- Improved type definitions in `ObjectFolderOrObjectsDuplicate.js` and `useBulkObjectOperations.js`.
- Cleaned up formatting in various files for better readability.
@ViktorVovk
ViktorVovk marked this pull request as ready for review August 12, 2026 12:19
@ViktorVovk
ViktorVovk requested a review from 4ian as a code owner August 12, 2026 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant