-
Notifications
You must be signed in to change notification settings - Fork 26
Extra keys UI #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extra keys UI #10
Conversation
📝 WalkthroughWalkthroughThe ExtraKeys component layout is restructured from a single horizontal row to a multi-row grid format. The internal interaction handler is renamed from Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@src/components/Trackpad/ExtraKeys.tsx`:
- Around line 27-33: The button in the ExtraKeys component is missing an
explicit type which can cause accidental form submissions; update the JSX button
element inside the ExtraKeys render (the <button ... onPointerDown={e =>
press(e, k)}>) to include type="button" so each key button does not act as a
submit button; locate the button that uses the key variable k and the press
handler and add the type attribute.
- Around line 24-26: The row mapping uses the array index as a React key which
can cause state/order glitches; update the JSX mapping over ROWS in
ExtraKeys.tsx to use a stable unique identifier instead of the index (e.g., a
precomputed id on each row object or a deterministic string from the row
contents) so replace key={i} with something like key={row.id} or
key={row.map(k=>k.label).join('-')} while preserving the existing ROWS constant
and the inner row.map(k => ...) rendering.
| {ROWS.map((row, i) => ( | ||
| <div key={i} className="flex gap-2 justify-center"> | ||
| {row.map(k => ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a stable key for rows (avoid array index).
Line 25 uses the array index as a key, which can cause state glitches if rows ever reorder.
✅ Suggested fix
- {ROWS.map((row, i) => (
- <div key={i} className="flex gap-2 justify-center">
+ {ROWS.map(row => (
+ <div key={row.join("|")} className="flex gap-2 justify-center">📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| {ROWS.map((row, i) => ( | |
| <div key={i} className="flex gap-2 justify-center"> | |
| {row.map(k => ( | |
| {ROWS.map(row => ( | |
| <div key={row.join("|")} className="flex gap-2 justify-center"> | |
| {row.map(k => ( |
🧰 Tools
🪛 Biome (2.3.13)
[error] 25-25: Avoid using the index of an array as key property in an element.
This is the source of the key value.
The order of the items may change, and this also affects performances and component state.
Check the React documentation.
(lint/suspicious/noArrayIndexKey)
🤖 Prompt for AI Agents
In `@src/components/Trackpad/ExtraKeys.tsx` around lines 24 - 26, The row mapping
uses the array index as a React key which can cause state/order glitches; update
the JSX mapping over ROWS in ExtraKeys.tsx to use a stable unique identifier
instead of the index (e.g., a precomputed id on each row object or a
deterministic string from the row contents) so replace key={i} with something
like key={row.id} or key={row.map(k=>k.label).join('-')} while preserving the
existing ROWS constant and the inner row.map(k => ...) rendering.
| <button | ||
| key={k} | ||
| className="btn btn-sm btn-neutral min-w-14 | ||
| " | ||
| onPointerDown={e => press(e, k)} | ||
| > | ||
| {k} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add explicit button type to avoid accidental form submits.
Line 27-33 should set type="button" to prevent default submit behavior.
✅ Suggested fix
<button
key={k}
+ type="button"
className="btn btn-sm btn-neutral min-w-14
"
onPointerDown={e => press(e, k)}
>🧰 Tools
🪛 Biome (2.3.13)
[error] 27-33: Provide an explicit type prop for the button element.
The default type of a button is submit, which causes the submission of a form when placed inside a form element. This is likely not the behaviour that you want inside a React application.
Allowed button types are: submit, button or reset
(lint/a11y/useButtonType)
🤖 Prompt for AI Agents
In `@src/components/Trackpad/ExtraKeys.tsx` around lines 27 - 33, The button in
the ExtraKeys component is missing an explicit type which can cause accidental
form submissions; update the JSX button element inside the ExtraKeys render (the
<button ... onPointerDown={e => press(e, k)}>) to include type="button" so each
key button does not act as a submit button; locate the button that uses the key
variable k and the press handler and add the type attribute.
This PR updates the Extra Keys section UI to better match the layout described in the Rein wiki.
Changes: