Skip to content

fix(ui-kit): don't hijack Cmd/Ctrl+B Bold in text fields (SidebarProvider) (#8305) - #8341

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
jeffrey701:fix-sidebar-cmdb-typing-guard-8305
Jul 24, 2026
Merged

fix(ui-kit): don't hijack Cmd/Ctrl+B Bold in text fields (SidebarProvider) (#8305)#8341
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
jeffrey701:fix-sidebar-cmdb-typing-guard-8305

Conversation

@jeffrey701

Copy link
Copy Markdown
Contributor

Summary

SidebarProvider's document-level Cmd/Ctrl+B keydown handler (packages/loopover-ui-kit/src/components/sidebar.tsx) toggled the sidebar and called preventDefault() regardless of what had focus — so typing Cmd/Ctrl+B inside a text <input>, <textarea>, or contenteditable element hijacked the browser-native Bold shortcut and toggled the sidebar instead, anywhere a SidebarProvider is mounted.

  • Add an isTyping(event.target) guard to handleKeyDown that returns early — before preventDefault()/toggleSidebar() — when the target is a form field or contenteditable element. It mirrors the exact helper the repo's two other global keydown handlers already use (apps/loopover-ui/src/components/site/keyboard-shortcuts.tsx:80-84 and app-shell.tsx:129-131): tagName === "INPUT" | "TEXTAREA" | "SELECT" or isContentEditable.
  • The existing metaKey/ctrlKey + key === "b" condition is unchanged for the non-typing case; toggleSidebar, the cookie persistence, and everything else in SidebarProvider are untouched.

Validation

  • New packages/loopover-ui-kit/src/components/sidebar.test.tsx (none existed) — the regression test the deliverable asks for: Cmd/Ctrl+B from document.body toggles the sidebar and prevents the default; Cmd/Ctrl+B from an <input> / <textarea> / a contenteditable element does not toggle and does not preventDefault(); and an unrelated Cmd/Ctrl chord is left alone.
  • @loopover/ui-kit: full vitest run (22 tests) green, tsc typecheck green, prettier --check clean, tsc build green. (packages/loopover-ui-kit is intentionally out of the root vitest.config.ts coverage.include and not Codecov-gated, per the issue — this adds the regression test its own suite requires.)

Closes #8305

@jeffrey701
jeffrey701 requested a review from JSONbored as a code owner July 24, 2026 10:40
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 24, 2026
@loopover-orb

loopover-orb Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-24 10:46:33 UTC

2 files · 1 AI reviewer · no blockers · readiness 98/100 · CI green · clean

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This diff adds an isTyping(event.target) guard to SidebarProvider's global Cmd/Ctrl+B keydown handler, returning early before preventDefault()/toggleSidebar() when focus is in an INPUT/TEXTAREA/SELECT or contenteditable element — fixing the reported hijack of the browser-native Bold shortcut. The guard is placed correctly (before both preventDefault and toggleSidebar), mirrors the existing isTyping pattern used in keyboard-shortcuts.tsx and app-shell.tsx, and is accompanied by a new regression test file covering the toggle case, the three typing-target cases, and an unrelated-chord case. The change is narrow, correctly targeted, and the test exercises the real code path rather than a fabricated one.

Nits — 3 non-blocking

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ✅ Gate result — Passing (No configured blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #8305
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 64 registered-repo PR(s), 29 merged, 16 issue(s).
Contributor context ✅ Confirmed Gittensor contributor jeffrey701; Gittensor profile; 64 PR(s), 16 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: moderate
Linked issue satisfaction

Addressed
The diff adds an isTyping guard that mirrors the repo's existing helper (checking INPUT/TEXTAREA/SELECT/isContentEditable) and returns early before preventDefault()/toggleSidebar(), exactly as the issue requested, while leaving toggleSidebar and cookie logic untouched. It also adds the required sidebar.test.tsx covering both the non-typing toggle case and the guarded input/textarea/contenteditable

Review context
  • Author: jeffrey701
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: Rust, TypeScript, Clojure, JavaScript
  • Official Gittensor activity: 64 PR(s), 16 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Keep the PR focused and include validation evidence before maintainer review.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
🧪 Chat with LoopOver

Ask LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @loopover ask &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat &lt;question&gt; answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

Full command reference: https://loopover.ai/docs/loopover-commands

🧪 Experimental — new and may change.

Visual preview
Route Viewport Before (production) After (this PR's preview) Diff
/ desktop before /
before /
after /
after /
/ mobile before / (mobile)
before / (mobile)
after / (mobile)
after / (mobile)

Click any thumbnail to open the full-size screenshot. Before = production · After = this PR's preview deploy.

Scroll preview
Route Before (production) After (this PR's preview)
/ before / (scroll)
before / (scroll)
after / (scroll)
after / (scroll)

A short scroll-through clip (desktop) — click either thumbnail to open the full animation. Evidence for scroll-linked behavior a single screenshot can't show.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

@loopover-orb loopover-orb Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LoopOver approves — the gate is satisfied and CI is green.

@loopover-orb
loopover-orb Bot merged commit 2ae66d6 into JSONbored:main Jul 24, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

1 participant