hyperframes icon indicating copy to clipboard operation
hyperframes copied to clipboard

Element picker: Esc cancels, and the hovered element shows its tag and class

Open miguel-heygen opened this issue 1 month ago • 2 comments

useElementPicker (packages/studio/src/hooks/useElementPicker.ts) has no way to back out with the keyboard, and while hovering it is hard to tell which nested element you are about to pick.

Done when

  • Esc leaves pick mode and restores the previous selection.
  • While picking, a small label next to the hovered element shows its tag plus id or first class (for example div.title).
  • Tests for Esc and for the label text.

Desktop candidate: this component is also used by the HyperFrames Desktop app, so the change reaches it with the next version bump.

Reviewer: @miguel-heygen. New to the repo? Start with CONTRIBUTING.md; run bun install, then the package's tests, before opening a PR.

miguel-heygen avatar Oct 14 '26 04:10 miguel-heygen

I'd like to take this one.

Plan: the runtime already handles Esc inside the preview and posts pick-mode-cancelled, so the gap is Esc while focus is in the studio (toolbar, panels). I'd add a keydown listener in useElementPicker while pick mode is on that calls disablePick, and keep the picked element from when pick mode started so cancelling restores it.

For the label, the runtime already posts element-hovered with the element info, which the studio doesn't use yet. I'd show tag#id or tag.class next to the hovered element from that, plus tests for Esc and the label text. I'll stay clear of #4727 since it touches picker labels in core.

Does that sound right?

yabhinav1 avatar Oct 14 '26 10:10 yabhinav1

I’m planning to implement the accepted scope: Studio-focus Escape cancellation that restores the pre-pick selection, plus a compact tag#id / tag.class / tag hover identifier driven by the existing validated picker messages, with listener, stale-iframe, zoom/geometry, and lifecycle regression coverage.

@yabhinav1, I saw your earlier interest and found no active PR or announced implementation. I’ll proceed from current main, but if you are already working on this, please say so and I’ll coordinate rather than duplicate your contribution.

Muzzy5150 avatar Oct 31 '26 20:10 Muzzy5150