refactor(flyout): migrate Flyout from Flow to TypeScript - #4767
refactor(flyout): migrate Flyout from Flow to TypeScript#4767bonchevskyi wants to merge 1 commit into
Conversation
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (13)
✨ 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 |
|
Caution CodeRabbit couldn't update its existing comment. The review summary may be out of date. Error details |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/components/flyout/__tests__/Flyout.test.tsx (1)
378-428: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winMake the hover tests observe the handler calls.
The tests register Sinon expectations inside timers after they invoke the handler.
openOverlay()runs at the configured delay before the expectation at 310 ms. A synchronous Jest test can finish before either timer executes.The positive custom-delay and hover-leave cases also use
openOnHover: false.Flyoutreturns without scheduling open or close work in that state.Register each expectation before invoking the handler. Set
openOnHover: truefor positive paths. Advance the controlled timer through the configured delay before verification.🤖 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/flyout/__tests__/Flyout.test.tsx` around lines 378 - 428, Update the handleButtonHover() and handleButtonHoverLeave() tests to set Sinon expectations before invoking the handlers, use openOnHover: true for positive open/close paths, and advance the controlled timer through each configured delay before asserting. Ensure the tests synchronously observe the scheduled handler calls rather than registering expectations inside delayed callbacks, while retaining never expectations for negative paths.
🤖 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/flyout/Overlay.tsx`:
- Around line 7-16: Prevent Overlay’s caller-provided onKeyDown from overriding
FocusTrap’s internal keyboard handling. Update the Overlay keyboard flow around
handleOverlayKeyDown to extract or otherwise exclude onKeyDown from rest, then
invoke the supplied handler alongside the existing Escape-close and Tab-trapping
behavior; alternatively, make FocusTrap compose both handlers.
---
Outside diff comments:
In `@src/components/flyout/__tests__/Flyout.test.tsx`:
- Around line 378-428: Update the handleButtonHover() and
handleButtonHoverLeave() tests to set Sinon expectations before invoking the
handlers, use openOnHover: true for positive open/close paths, and advance the
controlled timer through each configured delay before asserting. Ensure the
tests synchronously observe the scheduled handler calls rather than registering
expectations inside delayed callbacks, while retaining never expectations for
negative paths.
🪄 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: 14e1a753-6323-4b45-9f60-53d1042386c0
📒 Files selected for processing (13)
src/components/flyout/Flyout.js.flowsrc/components/flyout/Flyout.stories.tsxsrc/components/flyout/Flyout.tsxsrc/components/flyout/FlyoutContext.js.flowsrc/components/flyout/FlyoutContext.tssrc/components/flyout/Overlay.js.flowsrc/components/flyout/Overlay.tsxsrc/components/flyout/OverlayHeader.tsxsrc/components/flyout/__tests__/Flyout.test.tsxsrc/components/flyout/__tests__/Overlay.test.tsxsrc/components/flyout/__tests__/OverlayHeader.test.tsxsrc/components/flyout/index.js.flowsrc/components/flyout/index.ts
💤 Files with no reviewable changes (2)
- src/components/flyout/Flyout.stories.tsx
- src/components/flyout/OverlayHeader.tsx
Convert Flyout component to TypeScript
This PR converts
src/components/flyoutfrom JavaScript with Flow to TypeScript.Changes
Flyout.jstoFlyout.tsxwith exportedFlyoutPropsinterfaceOverlay.jstoOverlay.tsxwith exportedOverlayPropsinterfaceFlyoutContext.jstoFlyoutContext.tswith exportedFlyoutContextValuesinterfaceindex.jstoindex.ts, re-exporting the components and their types__tests__/Flyout.test.js,Overlay.test.js, andOverlayHeader.test.jsto.test.tsx.js.flowfiles for backward compatibility@ts-ignores fromOverlayHeader.tsxandFlyout.stories.tsxnow that sibling modules are TypeScriptContract
Testing
src/components/flyout; all 78 passyarn lint:tsandflow checkpassComponents/Flyout) that behavior is unchangedSummary by CodeRabbit
New Features
Tests