puck icon indicating copy to clipboard operation
puck copied to clipboard

Add move up and down hotkeys

Open cihad opened this issue 4 weeks ago • 1 comments

Description

The following shortcuts would be nice.

For slotted components

move selected component to left (horizontal layout) move selected component to right (horizontal layout) move selected component to down (vertical layout, same as right arrow) move selected component to up (vertical layout, same as left arrow)

It could be developed as a feature. Or is there a resource on how I can easily implement it?

cihad avatar Nov 26 '25 12:11 cihad

Hey @cihad!

Thanks for requesting this.

We do have other issues tracking the addition of copy and paste functionality (#1113), and the delete hotkey has been added to the main branch and will be released with the next version (#1132).

The move hotkeys are interesting. We do have an issue tracking the addition of move up and down actions in the action bar (#668), which has a PR open but is currently blocked by a bug.
However, that issue doesn't request side-to-side movement or hotkeys. That said, moving elements left and right is essentially the same as moving them up and down in the document's natural flow. It mostly depends on your container's display property. From Puck’s perspective, the data structure is still just an array, and your component is an item inside that array, so you'd perform the same operation for both types of movement.

I'll leave this open to track moving items up and down via the keyboard. If we decide to also support the left and right arrows, I think we could map the same behavior to them as follows:

  • and move items up
  • and move items down

But, I'm not sure we want to support left and right arrows, as this could be confusing in certain layouts display options. Users might expect different behaviors depending on context (RTL come to mind or row-reverse in flex containers).

FedericoBonel avatar Nov 27 '25 02:11 FedericoBonel