fix(webapp): avoid mutating render inputs - #4716
Conversation
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
| const startIndex = items | ||
| .slice(0, index) | ||
| .reduce((count, previousSection) => count + previousSection.items.length, 0); | ||
|
|
||
| return ( | ||
| <Fragment key={index}> | ||
| {children(section.items as ItemFromSection<TItem>[], { | ||
| shortcutsEnabled: enableItemShortcuts, | ||
| section: { | ||
| title: section.title, | ||
| startIndex: count - 1, | ||
| startIndex, |
There was a problem hiding this comment.
🔍 Section startIndex changes keyboard shortcut numbering for grouped selects
This is not just a purity refactor — it changes user-visible behavior. Previously the accumulator started at items.at(index - 1), which for index === 0 resolves to the last section (negative index wrap), and startIndex was then count - 1. For a single-section list of N items the old start index was N - 1, so the first item's shortcut was String(N + 1) instead of 1, and items pushing adjustedIndex > 9 got no shortcut at all (apps/webapp/app/components/primitives/Select.tsx:615-622). The new reduce yields the true count of preceding items (0 for the first section), so grouped/sectioned selects now get shortcuts starting at 1 and more items receive shortcuts. That looks like the intended correction, but reviewers relying on the old numbering (docs, tests, muscle memory) should be aware the visible shortcut keys shift.
Was this helpful? React with 👍 or 👎 to provide feedback.
Summary
Keeps render inputs and shared regular expressions immutable. Grouped selects now compute each section's shortcut offset directly from preceding sections, which also makes numeric shortcuts follow the displayed item order reliably.