Skip to content

PLASMA-7392: improve types in portal props#2896

Open
shuga2704 wants to merge 1 commit into
devfrom
plasma-7392
Open

PLASMA-7392: improve types in portal props#2896
shuga2704 wants to merge 1 commit into
devfrom
plasma-7392

Conversation

@shuga2704

@shuga2704 shuga2704 commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Core

Autocomplete, Dropdown, Popover, Popup

  • улучшена типизация свойств portal;

What/why changed

  • улучшена типизация свойств portal;

Summary by CodeRabbit

  • Bug Fixes
    • Improved type compatibility for portal/frame/root refs across Autocomplete, Dropdown, Popover, and Popup, now supporting refs whose referenced element may be null at runtime.
  • Tests
    • Updated Popover API typing checks to match the new frame ref 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

@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Six type declaration files in plasma-new-hope components and a test file receive single-line updates: portal props in AutocompleteProps and DropdownProps, and frame props in CustomPopoverProps and PopupProps, are widened from RefObject<HTMLElement> to RefObject<HTMLElement | null>. Internal FloatingPortalReturnedProps.root types and test assertions are updated accordingly.

Changes

RefObject Nullability Widening

Layer / File(s) Summary
Portal and frame prop type widening
packages/plasma-new-hope/src/components/Autocomplete/Autocomplete.types.ts, packages/plasma-new-hope/src/components/Dropdown/Dropdown.types.ts, packages/plasma-new-hope/src/components/Popover/Popover.types.ts, packages/plasma-new-hope/src/components/Popup/Popup.types.ts
portal in AutocompleteProps and DropdownProps, and frame in CustomPopoverProps and PopupProps, each change from RefObject<HTMLElement> to `RefObject<HTMLElement
FloatingPopover implementations and test assertions
packages/plasma-new-hope/src/components/Autocomplete/FloatingPopover.tsx, packages/plasma-new-hope/src/components/Dropdown/FloatingPopover.tsx, utils/api-tests/src/components/Popover/Popover.api.test.tsx
FloatingPortalReturnedProps.root types in Autocomplete and Dropdown FloatingPopover modules are updated to match the widened public types, and Popover API test expectations are updated to assert the nullable ref type.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐇 Four tiny tweaks, a null allowed,
The refs now flex with HTMLs shroud.
No element? No fuss, no fright—
The portal opens, null in sight.
Hippity-hop, the types are right! 🌿

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: updating type annotations for portal properties in UI components to accept RefObject<HTMLElement | null> instead of RefObject, improving type safety and consistency.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch plasma-7392

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 and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4f32198 and d08fbbc.

📒 Files selected for processing (4)
  • packages/plasma-new-hope/src/components/Autocomplete/Autocomplete.types.ts
  • packages/plasma-new-hope/src/components/Dropdown/Dropdown.types.ts
  • packages/plasma-new-hope/src/components/Popover/Popover.types.ts
  • packages/plasma-new-hope/src/components/Popup/Popup.types.ts

Comment thread packages/plasma-new-hope/src/components/Dropdown/Dropdown.types.ts
@github-actions

Copy link
Copy Markdown
Contributor

Theme Builder app deployed!

https://plasma.sberdevices.ru/pr/plasma-theme-builder-pr-2896/

@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Documentation preview deployed!

website: https://plasma.sberdevices.ru/pr/pr-2896/
asdk storybook: https://plasma.sberdevices.ru/pr/pr-2896/asdk-storybook/
b2c storybook: https://plasma.sberdevices.ru/pr/pr-2896/b2c-storybook/
giga storybook: https://plasma.sberdevices.ru/pr/pr-2896/giga-storybook/
homeds storybook: https://plasma.sberdevices.ru/pr/pr-2896/homeds-storybook/
new-hope storybook: https://plasma.sberdevices.ru/pr/pr-2896/new-hope-storybook/
web storybook: https://plasma.sberdevices.ru/pr/pr-2896/web-storybook/
sdds-bizcom storybook: https://plasma.sberdevices.ru/pr/pr-2896/sdds-bizcom-storybook/
sdds-cs storybook: https://plasma.sberdevices.ru/pr/pr-2896/sdds-cs-storybook/
sdds-dfa storybook: https://plasma.sberdevices.ru/pr/pr-2896/sdds-dfa-storybook/
sdds-finai storybook: https://plasma.sberdevices.ru/pr/pr-2896/sdds-finai-storybook/
sdds-insol storybook: https://plasma.sberdevices.ru/pr/pr-2896/sdds-insol-storybook/
sdds-netology storybook: https://plasma.sberdevices.ru/pr/pr-2896/sdds-netology-storybook/
sdds-os storybook: https://plasma.sberdevices.ru/pr/pr-2896/sdds-os-storybook/
sdds-platform-ai storybook: https://plasma.sberdevices.ru/pr/pr-2896/sdds-platform-ai-storybook/
sdds-sbcom storybook: https://plasma.sberdevices.ru/pr/pr-2896/sdds-sbcom-storybook/
sdds-scan storybook: https://plasma.sberdevices.ru/pr/pr-2896/sdds-scan-storybook/
sdds-serv storybook: https://plasma.sberdevices.ru/pr/pr-2896/sdds-serv-storybook/
ui storybook: https://plasma.sberdevices.ru/pr/pr-2896/ui-storybook/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants