Skip to content

PLASMA-5874: overlay click handler for Sheet and BottomSheet - #3021

Open
vmytnik wants to merge 2 commits into
devfrom
PLASMA-5874.sheet-overlay-click
Open

PLASMA-5874: overlay click handler for Sheet and BottomSheet#3021
vmytnik wants to merge 2 commits into
devfrom
PLASMA-5874.sheet-overlay-click

Conversation

@vmytnik

@vmytnik vmytnik commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Core

BottomSheet, Sheet

  • добавлен колбек onOverlayClick
  • добавлен колбек onEscClick
  • вызов onClose по нажатию Esc по-умолчанию

What/why changed

Summary by CodeRabbit

New Features

  • Added Escape-key handling for BottomSheet and Sheet, with configurable closing behavior and custom callbacks.
  • Added customizable overlay-click handling for both components.
  • Escape actions now work predictably when multiple sheets or bottom sheets are open.

Tests

  • Expanded API coverage for BottomSheet and Sheet, including overlay clicks, Escape-key behavior, and supported usage patterns.
📦 Published PR as canary version: Canary Versions

✨ Test out this PR locally via:

npm install @salutejs/plasma-asdk@0.387.0-canary.3021.31179775631.0
npm install @salutejs/plasma-b2c@1.629.0-canary.3021.31179775631.0
npm install @salutejs/plasma-colors@0.18.0-canary.3021.31179775631.0
npm install @salutejs/plasma-core@1.236.0-canary.3021.31179775631.0
npm install @salutejs/plasma-giga@0.356.0-canary.3021.31179775631.0
npm install @salutejs/plasma-homeds@0.356.0-canary.3021.31179775631.0
npm install @salutejs/plasma-hope@1.383.0-canary.3021.31179775631.0
npm install @salutejs/plasma-icons@1.245.0-canary.3021.31179775631.0
npm install @salutejs/plasma-new-hope@0.373.0-canary.3021.31179775631.0
npm install @salutejs/plasma-tokens@1.147.0-canary.3021.31179775631.0
npm install @salutejs/plasma-tokens-b2b@1.61.0-canary.3021.31179775631.0
npm install @salutejs/plasma-tokens-b2c@0.72.0-canary.3021.31179775631.0
npm install @salutejs/plasma-tokens-core@0.9.0-canary.3021.31179775631.0
npm install @salutejs/plasma-tokens-web@1.76.0-canary.3021.31179775631.0
npm install @salutejs/plasma-typo@0.49.0-canary.3021.31179775631.0
npm install @salutejs/plasma-web@1.631.0-canary.3021.31179775631.0
npm install @salutejs/sdds-bizcom@0.361.0-canary.3021.31179775631.0
npm install @salutejs/sdds-cs@0.365.0-canary.3021.31179775631.0
npm install @salutejs/sdds-dfa@0.359.0-canary.3021.31179775631.0
npm install @salutejs/sdds-finai@0.352.0-canary.3021.31179775631.0
npm install @salutejs/sdds-insol@0.356.0-canary.3021.31179775631.0
npm install @salutejs/sdds-insol-next@0.355.0-canary.3021.31179775631.0
npm install @salutejs/sdds-netology@0.360.0-canary.3021.31179775631.0
npm install @salutejs/sdds-os@0.31.0-canary.3021.31179775631.0
npm install @salutejs/sdds-platform-ai@0.360.0-canary.3021.31179775631.0
npm install @salutejs/sdds-sbcom@0.361.0-canary.3021.31179775631.0
npm install @salutejs/sdds-scan@0.359.0-canary.3021.31179775631.0
npm install @salutejs/sdds-serv@0.360.0-canary.3021.31179775631.0
npm install @salutejs/core-themes@0.37.0-canary.3021.31179775631.0
npm install @salutejs/plasma-themes@0.59.0-canary.3021.31179775631.0
npm install @salutejs/sdds-themes@0.74.0-canary.3021.31179775631.0
npm install @salutejs/sdds-api-tests@0.18.0-canary.3021.31179775631.0
npm install @salutejs/plasma-cy-utils@0.166.0-canary.3021.31179775631.0
npm install @salutejs/plasma-sb-utils@0.237.0-canary.3021.31179775631.0
npm install @salutejs/plasma-tokens-utils@0.57.0-canary.3021.31179775631.0
# or 
yarn add @salutejs/plasma-asdk@0.387.0-canary.3021.31179775631.0
yarn add @salutejs/plasma-b2c@1.629.0-canary.3021.31179775631.0
yarn add @salutejs/plasma-colors@0.18.0-canary.3021.31179775631.0
yarn add @salutejs/plasma-core@1.236.0-canary.3021.31179775631.0
yarn add @salutejs/plasma-giga@0.356.0-canary.3021.31179775631.0
yarn add @salutejs/plasma-homeds@0.356.0-canary.3021.31179775631.0
yarn add @salutejs/plasma-hope@1.383.0-canary.3021.31179775631.0
yarn add @salutejs/plasma-icons@1.245.0-canary.3021.31179775631.0
yarn add @salutejs/plasma-new-hope@0.373.0-canary.3021.31179775631.0
yarn add @salutejs/plasma-tokens@1.147.0-canary.3021.31179775631.0
yarn add @salutejs/plasma-tokens-b2b@1.61.0-canary.3021.31179775631.0
yarn add @salutejs/plasma-tokens-b2c@0.72.0-canary.3021.31179775631.0
yarn add @salutejs/plasma-tokens-core@0.9.0-canary.3021.31179775631.0
yarn add @salutejs/plasma-tokens-web@1.76.0-canary.3021.31179775631.0
yarn add @salutejs/plasma-typo@0.49.0-canary.3021.31179775631.0
yarn add @salutejs/plasma-web@1.631.0-canary.3021.31179775631.0
yarn add @salutejs/sdds-bizcom@0.361.0-canary.3021.31179775631.0
yarn add @salutejs/sdds-cs@0.365.0-canary.3021.31179775631.0
yarn add @salutejs/sdds-dfa@0.359.0-canary.3021.31179775631.0
yarn add @salutejs/sdds-finai@0.352.0-canary.3021.31179775631.0
yarn add @salutejs/sdds-insol@0.356.0-canary.3021.31179775631.0
yarn add @salutejs/sdds-insol-next@0.355.0-canary.3021.31179775631.0
yarn add @salutejs/sdds-netology@0.360.0-canary.3021.31179775631.0
yarn add @salutejs/sdds-os@0.31.0-canary.3021.31179775631.0
yarn add @salutejs/sdds-platform-ai@0.360.0-canary.3021.31179775631.0
yarn add @salutejs/sdds-sbcom@0.361.0-canary.3021.31179775631.0
yarn add @salutejs/sdds-scan@0.359.0-canary.3021.31179775631.0
yarn add @salutejs/sdds-serv@0.360.0-canary.3021.31179775631.0
yarn add @salutejs/core-themes@0.37.0-canary.3021.31179775631.0
yarn add @salutejs/plasma-themes@0.59.0-canary.3021.31179775631.0
yarn add @salutejs/sdds-themes@0.74.0-canary.3021.31179775631.0
yarn add @salutejs/sdds-api-tests@0.18.0-canary.3021.31179775631.0
yarn add @salutejs/plasma-cy-utils@0.166.0-canary.3021.31179775631.0
yarn add @salutejs/plasma-sb-utils@0.237.0-canary.3021.31179775631.0
yarn add @salutejs/plasma-tokens-utils@0.57.0-canary.3021.31179775631.0

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

Sheet interaction controls

Layer / File(s) Summary
Escape handling contract and hook
packages/plasma-new-hope/src/hooks/useEscKeyDown.ts, packages/plasma-new-hope/src/hooks/index.ts, packages/plasma-new-hope/src/components/BottomSheet/BottomSheet.types.ts, packages/plasma-new-hope/src/components/Sheet/Sheet.types.ts
Adds useEscKeyDown and documents onOverlayClick, closeOnEsc, and onEscKeyDown with onClose fallback behavior.
BottomSheet and Sheet event wiring
packages/plasma-new-hope/src/components/BottomSheet/BottomSheet.tsx, packages/plasma-new-hope/src/components/Sheet/Sheet.tsx
Adds Escape-key handling and routes overlay clicks to custom callbacks or onClose.
API validation and generation configuration
utils/api-tests/src/components/BottomSheet/BottomSheet.api.test.tsx, utils/api-tests/src/components/Sheet/Sheet.api.test.tsx, utils/api-tests/script.mjs
Adds type-level API coverage and updates component exclusions for configured libraries.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant BottomSheetOrSheet
  participant useEscKeyDown
  participant Callback
  User->>BottomSheetOrSheet: press Escape
  BottomSheetOrSheet->>useEscKeyDown: process opened and closeOnEsc
  useEscKeyDown->>Callback: invoke onEscKeyDown or onClose
  User->>BottomSheetOrSheet: click overlay
  BottomSheetOrSheet->>Callback: invoke onOverlayClick or onClose
Loading

Possibly related PRs

Suggested reviewers: shuga2704, titankuzmich, igoryar

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly identifies the addition of overlay click handling for both Sheet and BottomSheet, which is a primary change in the pull request.
✨ 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-5874.sheet-overlay-click

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

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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/hooks/useEscKeyDown.ts`:
- Around line 31-37: The useEffect listener registration in useEscKeyDown must
ensure Escape is handled only by the active, topmost sheet. Replace the
per-instance window listener behavior with an active-sheet stack or equivalent
topmost-sheet coordination, so nested sheets do not both invoke onKeyDown for
one key press while preserving cleanup when a sheet closes.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a63db746-ab74-4660-b75e-be66e77a91ad

📥 Commits

Reviewing files that changed from the base of the PR and between 54970bf and c43e1c8.

📒 Files selected for processing (9)
  • packages/plasma-new-hope/src/components/BottomSheet/BottomSheet.tsx
  • packages/plasma-new-hope/src/components/BottomSheet/BottomSheet.types.ts
  • packages/plasma-new-hope/src/components/Sheet/Sheet.tsx
  • packages/plasma-new-hope/src/components/Sheet/Sheet.types.ts
  • packages/plasma-new-hope/src/hooks/index.ts
  • packages/plasma-new-hope/src/hooks/useEscKeyDown.ts
  • utils/api-tests/script.mjs
  • utils/api-tests/src/components/BottomSheet/BottomSheet.api.test.tsx
  • utils/api-tests/src/components/Sheet/Sheet.api.test.tsx

Comment thread packages/plasma-new-hope/src/hooks/useEscKeyDown.ts Outdated
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Theme Builder app deployed!

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

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Documentation preview deployed!

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

@Yakutoc
Yakutoc requested review from IgorYar and removed request for Yakutoc, Yeti-or and neretin-trike August 7, 2026 04:32
@vmytnik
vmytnik force-pushed the PLASMA-5874.sheet-overlay-click branch from c43e1c8 to 59bd9e9 Compare August 7, 2026 12:31

@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: 1

🤖 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/hooks/useEscKeyDown.ts`:
- Around line 18-24: Update the stack registration effect in useEscKeyDown so
every opened layer is registered regardless of closeOnEsc. Check whether the
layer is topmost before applying closeOnEsc, and only invoke onClose or
onEscKeyDown when that topmost layer allows Escape handling. Keep closeOnEsc in
callbackRef so prop updates do not remove and re-add the layer.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 51a180c3-5d96-4e6c-8423-134a0d209583

📥 Commits

Reviewing files that changed from the base of the PR and between c43e1c8 and 59bd9e9.

📒 Files selected for processing (1)
  • packages/plasma-new-hope/src/hooks/useEscKeyDown.ts

Comment thread packages/plasma-new-hope/src/hooks/useEscKeyDown.ts Outdated
@vmytnik
vmytnik force-pushed the PLASMA-5874.sheet-overlay-click branch from 59bd9e9 to 06245d0 Compare August 7, 2026 12:48
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