Repository navigation
fix(workspace-emoji): keep the ':' shortcode suggestions scrolled to the highlight - #13969
Merged
Merged
Conversation
…the highlight Arrow keys are handled by the input, so the highlight moved via cmdk's controlled `value` prop — a path that never runs cmdk's own scrollSelectedIntoView. Selection could walk below the visible list.
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe emoji suggestion popover now tracks its command list with a ref. When the popover opens or its command value or suggestions change, it scrolls the selected suggestion into view. If the suggestion is first in its group, the group heading is scrolled instead. Tests cover external selection changes after rerendering and stub DOM scrolling behavior. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
Type
:smiin a workspace-name field and a little emoji list pops up. Holding ↓ moved the highlight down the list but the list never scrolled, so the highlight disappeared below the visible area. Now the list follows the highlight.What Changed
WorkspaceEmojiSuggestionPopoverscrolls the selected suggestion into view whenever the selection changes, mirroring cmdk's ownscrollSelectedIntoView(including revealing the group heading when the first item is selected).Why
Arrow keys are handled in
useWorkspaceEmojiShortcodeInputbecause focus stays in the text input — it moves the highlight by setting cmdk's controlledvalueprop. cmdk only callsscrollSelectedIntoViewfrom its internalsetState('value', …)path; when the controlled prop changes externally it just writes state and re-renders ([email protected], theuseLayoutEffectonvalue). So nothing ever scrolled themax-h-56list.Matching the item by
data-valuerather thandata-selectedavoids depending on when cmdk's store emit lands relative to our effect.Fixed in the shared popover, so it covers all four consumers:
WorktreeDisplayNameField,WorktreeTitleInlineRename,SmartWorkspaceNameField,WorktreeJumpPalette.Linked Issue
Fixes #
Visual Proof
Not captured — happy to record a before/after if wanted. The behavior is covered by an automated regression test instead (see Testing).
Testing
Repro: focus any workspace-name field, type
:s, hold ↓ — before this change the highlight leaves the visible list; after, the list scrolls with it.pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/components/workspace-emoji/→ 6 passedNew
WorkspaceEmojiSuggestionPopover.test.tsxasserts the externally-selected item is scrolled into view; verified it fails with the new effect disabled and passes with itoxlint+typecheck:webcleanI manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Renderer-only, no platform-specific APIs, no wire/IPC surface — same behavior on macOS/Linux/Windows and over SSH/remote. The effect is a single
querySelectorAllover the ≤N suggestion items, only on selection change.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)Made with Orca 🐋