refactor(selector-dropdown): migrate SelectorDropdown from Flow to Ty… - #4758
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughSelectorDropdown now has a TypeScript implementation with Flow compatibility. It supports typed props, keyboard navigation, selection, accessibility, positioning, scrolling, and outside-click handling. Barrel exports and TypeScript-compatible tests were updated. ChangesSelectorDropdown migration
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/components/selector-dropdown/SelectorDropdown.js.flow (1)
135-137: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueGuard
child.keyaccess inhaveChildrenChanged.The TypeScript version at
SelectorDropdown.tsxlines 137-140 adds aReact.isValidElement(child)guard before readingchild.key. This Flow copy readschild.keydirectly. If a consumer passes a string or number child, the two implementations produce different key values. Align the Flow copy with the TypeScript implementation.♻️ Proposed fix
- const childrenKeys = React.Children.map(children, child => child.key); - const prevChildrenKeys = React.Children.map(prevChildren, child => child.key); + const childrenKeys = React.Children.map(children, child => (React.isValidElement(child) ? child.key : null)); + const prevChildrenKeys = React.Children.map(prevChildren, child => + React.isValidElement(child) ? child.key : null, + );🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/components/selector-dropdown/SelectorDropdown.js.flow` around lines 135 - 137, Update haveChildrenChanged in the Flow implementation to guard each child with React.isValidElement before reading child.key, matching the SelectorDropdown.tsx behavior and ensuring primitive children produce the same key values in both implementations.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/components/selector-dropdown/SelectorDropdown.tsx`:
- Around line 27-28: Update isPositionDynamic in the SelectorDropdownProps
TypeScript interface to be optional, matching the Flow declaration, defaultProps
behavior, and PopperComponentProps contract; leave its boolean type unchanged.
---
Nitpick comments:
In `@src/components/selector-dropdown/SelectorDropdown.js.flow`:
- Around line 135-137: Update haveChildrenChanged in the Flow implementation to
guard each child with React.isValidElement before reading child.key, matching
the SelectorDropdown.tsx behavior and ensuring primitive children produce the
same key values in both implementations.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 33724378-97e3-4045-a429-b252dc09ceb8
📒 Files selected for processing (6)
src/components/selector-dropdown/SelectorDropdown.js.flowsrc/components/selector-dropdown/SelectorDropdown.stories.tsxsrc/components/selector-dropdown/SelectorDropdown.tsxsrc/components/selector-dropdown/__tests__/SelectorDropdown.test.tsxsrc/components/selector-dropdown/index.js.flowsrc/components/selector-dropdown/index.ts
💤 Files with no reviewable changes (1)
- src/components/selector-dropdown/SelectorDropdown.stories.tsx
8f03f9c to
d74d5c5
Compare
d74d5c5 to
8c71e38
Compare
Merge Queue Status
This pull request spent 49 minutes 34 seconds in the queue, including 12 minutes 6 seconds running CI. Required conditions to merge
|
Convert SelectorDropdown component to TypeScript
This PR converts
src/components/selector-dropdownfrom JavaScript with Flow to TypeScript.Changes
SelectorDropdown.jstoSelectorDropdown.tsxwith exportedSelectorDropdownPropsinterfaceindex.jstoindex.ts, re-exporting the component and its typesSelectorDropdown.stories.jstoSelectorDropdown.stories.tsx__tests__/SelectorDropdown.test.jstoSelectorDropdown.test.tsx.js.flowfiles for backward compatibilityTesting
src/components/selector-dropdown; all 58 passyarn lint:tsandflow checkpassComponents/SelectorDropdown) that behavior is unchangedSummary by CodeRabbit