Skip to content

refactor(selector-dropdown): migrate SelectorDropdown from Flow to Ty… - #4758

Merged
mergify[bot] merged 2 commits into
box:masterfrom
bonchevskyi:refactor/flow-to-ts-selector-dropdown
Aug 11, 2026
Merged

refactor(selector-dropdown): migrate SelectorDropdown from Flow to Ty…#4758
mergify[bot] merged 2 commits into
box:masterfrom
bonchevskyi:refactor/flow-to-ts-selector-dropdown

Conversation

@bonchevskyi

@bonchevskyi bonchevskyi commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Convert SelectorDropdown component to TypeScript

This PR converts src/components/selector-dropdown from JavaScript with Flow to TypeScript.

Changes

  • Converted SelectorDropdown.js to SelectorDropdown.tsx with exported SelectorDropdownProps interface
  • Converted index.js to index.ts, re-exporting the component and its types
  • Converted SelectorDropdown.stories.js to SelectorDropdown.stories.tsx
  • Converted __tests__/SelectorDropdown.test.js to SelectorDropdown.test.tsx
  • Created .js.flow files for backward compatibility

Testing

  • Ran tests for src/components/selector-dropdown; all 58 pass
  • yarn lint:ts and flow check pass
  • Manually verified in Storybook (Components/SelectorDropdown) that behavior is unchanged

Summary by CodeRabbit

  • New Features
    • Added a configurable selector dropdown with dynamic positioning, scrolling, and optional titles or dividers.
    • Supports keyboard navigation, item selection, active-item highlighting, and closing when clicking outside.
    • Improved accessibility with appropriate interaction attributes and focus behavior.
    • Supports always-open mode and customizable selection, input, and keyboard callbacks.
  • Bug Fixes
    • Keeps active options visible while navigating through the dropdown.
  • Tests
    • Updated dropdown coverage and compatibility checks without changing expected behavior.

@bonchevskyi
bonchevskyi requested a review from a team as a code owner August 10, 2026 12:11
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c0a47108-f516-4e52-becf-62589ccf42f1

📥 Commits

Reviewing files that changed from the base of the PR and between d74d5c5 and 8c71e38.

📒 Files selected for processing (1)
  • src/components/selector-dropdown/SelectorDropdown.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/selector-dropdown/SelectorDropdown.tsx

Walkthrough

SelectorDropdown 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.

Changes

SelectorDropdown migration

Layer / File(s) Summary
Typed component contract and lifecycle
src/components/selector-dropdown/SelectorDropdown.tsx, src/components/selector-dropdown/SelectorDropdown.js.flow
Adds typed props and state, component initialization, child updates, refs, and document-listener cleanup.
Active-item and interaction state
src/components/selector-dropdown/SelectorDropdown.tsx, src/components/selector-dropdown/SelectorDropdown.js.flow
Implements active-item tracking, keyboard navigation, focus and input handling, outside-click closing, visibility changes, and selection callbacks.
Listbox rendering and positioning
src/components/selector-dropdown/SelectorDropdown.tsx, src/components/selector-dropdown/SelectorDropdown.js.flow
Adds accessible listbox rendering, cloned child options, titles, dividers, Popper positioning, selector props, and optional scrolling.
Exports and validation
src/components/selector-dropdown/index.ts, src/components/selector-dropdown/index.js.flow, src/components/selector-dropdown/__tests__/SelectorDropdown.test.tsx
Adds TypeScript and Flow exports and updates tests for TypeScript-compatible events, mocks, and assertions.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

Suggested labels: ready-to-merge

Suggested reviewers: vitali-usik, jpan-box

Poem

A rabbit typed the dropdown bright,
Keys hop left and right.
Popper sets the menu in place,
Tests check each choice and space.
Flow and TypeScript share the trail.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the primary change: migrating SelectorDropdown from Flow to TypeScript.
Description check ✅ Passed The description explains the migration, lists affected areas, and documents tests, lint, Flow, and Storybook verification.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/components/selector-dropdown/SelectorDropdown.js.flow (1)

135-137: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Guard child.key access in haveChildrenChanged.

The TypeScript version at SelectorDropdown.tsx lines 137-140 adds a React.isValidElement(child) guard before reading child.key. This Flow copy reads child.key directly. 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

📥 Commits

Reviewing files that changed from the base of the PR and between 84b90a7 and 8f03f9c.

📒 Files selected for processing (6)
  • src/components/selector-dropdown/SelectorDropdown.js.flow
  • src/components/selector-dropdown/SelectorDropdown.stories.tsx
  • src/components/selector-dropdown/SelectorDropdown.tsx
  • src/components/selector-dropdown/__tests__/SelectorDropdown.test.tsx
  • src/components/selector-dropdown/index.js.flow
  • src/components/selector-dropdown/index.ts
💤 Files with no reviewable changes (1)
  • src/components/selector-dropdown/SelectorDropdown.stories.tsx

Comment thread src/components/selector-dropdown/SelectorDropdown.tsx Outdated
vitali-usik
vitali-usik previously approved these changes Aug 11, 2026
Comment thread src/components/selector-dropdown/SelectorDropdown.tsx Outdated
Comment thread src/components/selector-dropdown/SelectorDropdown.tsx
@mergify mergify Bot added the queued label Aug 11, 2026
@mergify

mergify Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • Entered queue2026-08-11 15:26 UTC · Rule: Automatic strict merge · triggered by rule Automatic merge queue
  • Checks passed · in-place
  • Merged2026-08-11 16:16 UTC · at 8f0ff47ffd858b930337e3e92f1d929194b282cd · squash

This pull request spent 49 minutes 34 seconds in the queue, including 12 minutes 6 seconds running CI.

Required conditions to merge
  • github-review-approved [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Summary
    • check-neutral = Summary
    • check-skipped = Summary
  • any of [🛡 GitHub branch protection]:
    • check-success = lint_test_build
    • check-neutral = lint_test_build
    • check-skipped = lint_test_build
  • any of [🛡 GitHub branch protection]:
    • check-success = license/cla
    • check-neutral = license/cla
    • check-skipped = license/cla
  • any of [🛡 GitHub branch protection]:
    • check-success = lint_pull_request
    • check-neutral = lint_pull_request
    • check-skipped = lint_pull_request

@mergify
mergify Bot merged commit 5c1e82b into box:master Aug 11, 2026
9 of 10 checks passed
@mergify mergify Bot removed the queued label Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants