Skip to content

Feat/alt click cycle select#46

Merged
u8array merged 4 commits into
mainfrom
feat/alt-click-cycle-select
May 10, 2026
Merged

Feat/alt click cycle select#46
u8array merged 4 commits into
mainfrom
feat/alt-click-cycle-select

Conversation

@u8array
Copy link
Copy Markdown
Owner

@u8array u8array commented May 10, 2026

No description provided.

u8array added 2 commits May 10, 2026 12:01
Inverted shapes let users see objects layered behind them, but normal
click-to-select can only reach the topmost object at a point. Alt+click
now cycles through the stack: first click selects the topmost hit, each
subsequent Alt+click at (approximately) the same pointer position dives
one layer deeper, wrapping at the bottom.

Implemented with a native capture-phase mousedown listener on the canvas
container. Konva's getAllIntersections drives the hit-graph (handles
view rotation, pan offset, per-shape transforms transparently). A pure
nextCycleIndex helper holds the cycle state machine for unit testing.
Adds a hint in the Edit-properties section explaining the use case
(reaching objects hidden behind a filled or inverted shape) and a
row in the shortcut table for discoverability.
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements an Alt+click "select-below" feature, allowing users to cycle selection through stacked objects on the canvas. The changes include a new useAltClickCycle hook, a logic helper with unit tests, and updated documentation in the README. Review feedback identifies opportunities to optimize the hook by deferring the creation of the object ID set until intersections are confirmed and suggests removing a redundant null check for the next selected ID.

Comment thread src/components/Canvas/hooks/useAltClickCycle.ts
Comment thread src/components/Canvas/hooks/useAltClickCycle.ts
u8array added 2 commits May 10, 2026 12:26
…uard

Reviewer-spotted (gemini-code-assist on PR #46):
- Build the objIds lookup only after we know intersections is non-empty,
  so empty-canvas Alt+clicks skip the per-object map allocation.
- Add a comment on the `if (!nextId) return` guard noting that it is
  required by noUncheckedIndexedAccess even though the index is logically
  guaranteed valid.
The app already accepts both metaKey and ctrlKey (useGlobalShortcuts),
but the README documented only Ctrl-bindings, which is misleading for
Mac users. Inline `Ctrl/⌘` (and `Alt/⌥` for the new alt+click row)
keeps each shortcut self-contained without splitting the table.
@u8array u8array merged commit 8ee6336 into main May 10, 2026
2 checks passed
@u8array u8array deleted the feat/alt-click-cycle-select branch May 10, 2026 20:06
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