PLASMA-7392: improve types in portal props#2896
Conversation
📝 WalkthroughWalkthroughSix type declaration files in ChangesRefObject Nullability Widening
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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: 2
🤖 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 `@packages/plasma-new-hope/src/components/Autocomplete/Autocomplete.types.ts`:
- Line 38: The portal prop type widening in AutocompleteProps is not reflected
in the internal FloatingPopover contract. Update the
FloatingPortalReturnedProps.root type definition in FloatingPopover.tsx (which
currently expects React.RefObject<HTMLElement>) to accept
React.RefObject<HTMLElement | null> to match the widened portal prop signature.
This ensures the return type of getFloatingPortalProps() function is type-safe
and compatible with the portal prop's new null-inclusive type.
In `@packages/plasma-new-hope/src/components/Dropdown/Dropdown.types.ts`:
- Line 110: Update the downstream type declarations to accept nullable refs
consistently with the nullable portal type in DropdownProps. Change
DropdownInnerProps['portal'] from RefObject<HTMLElement> to
RefObject<HTMLElement | null>, and update FloatingPortalReturnedProps['root']
from React.RefObject<HTMLElement> to React.RefObject<HTMLElement | null>. This
ensures type consistency throughout the component hierarchy and maintains proper
null safety checks when the getFloatingPortalProps() function in
FloatingPopover.tsx passes the nullable portal ref as the root ref.
🪄 Autofix (Beta)
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: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 708bee87-8b65-48f2-92ea-6fb85da70940
📒 Files selected for processing (4)
packages/plasma-new-hope/src/components/Autocomplete/Autocomplete.types.tspackages/plasma-new-hope/src/components/Dropdown/Dropdown.types.tspackages/plasma-new-hope/src/components/Popover/Popover.types.tspackages/plasma-new-hope/src/components/Popup/Popup.types.ts
|
Theme Builder app deployed! https://plasma.sberdevices.ru/pr/plasma-theme-builder-pr-2896/ |
Core
Autocomplete, Dropdown, Popover, Popup
portal;What/why changed
portal;Summary by CodeRabbit
nullat runtime.frameref nullability.📦 Published PR as canary version:
Canary Versions✨ Test out this PR locally via:
npm install @salutejs/plasma-asdk@0.381.0-canary.2896.27808886164.0 npm install @salutejs/plasma-b2c@1.623.0-canary.2896.27808886164.0 npm install @salutejs/plasma-core@1.230.0-canary.2896.27808886164.0 npm install @salutejs/plasma-giga@0.350.0-canary.2896.27808886164.0 npm install @salutejs/plasma-homeds@0.350.0-canary.2896.27808886164.0 npm install @salutejs/plasma-hope@1.377.0-canary.2896.27808886164.0 npm install @salutejs/plasma-new-hope@0.367.0-canary.2896.27808886164.0 npm install @salutejs/plasma-ui@1.353.0-canary.2896.27808886164.0 npm install @salutejs/plasma-web@1.625.0-canary.2896.27808886164.0 npm install @salutejs/sdds-bizcom@0.355.0-canary.2896.27808886164.0 npm install @salutejs/sdds-cs@0.359.0-canary.2896.27808886164.0 npm install @salutejs/sdds-dfa@0.353.0-canary.2896.27808886164.0 npm install @salutejs/sdds-finai@0.346.0-canary.2896.27808886164.0 npm install @salutejs/sdds-insol@0.350.0-canary.2896.27808886164.0 npm install @salutejs/sdds-netology@0.354.0-canary.2896.27808886164.0 npm install @salutejs/sdds-os@0.25.0-canary.2896.27808886164.0 npm install @salutejs/sdds-platform-ai@0.354.0-canary.2896.27808886164.0 npm install @salutejs/sdds-sbcom@0.355.0-canary.2896.27808886164.0 npm install @salutejs/sdds-scan@0.353.0-canary.2896.27808886164.0 npm install @salutejs/sdds-serv@0.354.0-canary.2896.27808886164.0 npm install @salutejs/sdds-api-tests@0.12.0-canary.2896.27808886164.0 npm install @salutejs/plasma-cy-utils@0.160.0-canary.2896.27808886164.0 npm install @salutejs/plasma-sb-utils@0.231.0-canary.2896.27808886164.0 # or yarn add @salutejs/plasma-asdk@0.381.0-canary.2896.27808886164.0 yarn add @salutejs/plasma-b2c@1.623.0-canary.2896.27808886164.0 yarn add @salutejs/plasma-core@1.230.0-canary.2896.27808886164.0 yarn add @salutejs/plasma-giga@0.350.0-canary.2896.27808886164.0 yarn add @salutejs/plasma-homeds@0.350.0-canary.2896.27808886164.0 yarn add @salutejs/plasma-hope@1.377.0-canary.2896.27808886164.0 yarn add @salutejs/plasma-new-hope@0.367.0-canary.2896.27808886164.0 yarn add @salutejs/plasma-ui@1.353.0-canary.2896.27808886164.0 yarn add @salutejs/plasma-web@1.625.0-canary.2896.27808886164.0 yarn add @salutejs/sdds-bizcom@0.355.0-canary.2896.27808886164.0 yarn add @salutejs/sdds-cs@0.359.0-canary.2896.27808886164.0 yarn add @salutejs/sdds-dfa@0.353.0-canary.2896.27808886164.0 yarn add @salutejs/sdds-finai@0.346.0-canary.2896.27808886164.0 yarn add @salutejs/sdds-insol@0.350.0-canary.2896.27808886164.0 yarn add @salutejs/sdds-netology@0.354.0-canary.2896.27808886164.0 yarn add @salutejs/sdds-os@0.25.0-canary.2896.27808886164.0 yarn add @salutejs/sdds-platform-ai@0.354.0-canary.2896.27808886164.0 yarn add @salutejs/sdds-sbcom@0.355.0-canary.2896.27808886164.0 yarn add @salutejs/sdds-scan@0.353.0-canary.2896.27808886164.0 yarn add @salutejs/sdds-serv@0.354.0-canary.2896.27808886164.0 yarn add @salutejs/sdds-api-tests@0.12.0-canary.2896.27808886164.0 yarn add @salutejs/plasma-cy-utils@0.160.0-canary.2896.27808886164.0 yarn add @salutejs/plasma-sb-utils@0.231.0-canary.2896.27808886164.0