Repository navigation
[IRN-6874][BpkDrawer] Fix close button position regression when hideTitle is set - #4962
Conversation
SecondaryPanelProps was added to Props in 43.7.0 but never re-exported from index.ts, causing TS2742 in consumers whose declaration emit needs a stable import path for the type. Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]>
|
Visit https://backpack.github.io/storybook-prs/4962 to see this build running in a browser. |
…eTitle is set PR #4848 removed the ` ` spacer that was keeping the close button at the trailing end of the flex header when the title is visually hidden (position: absolute, so out of flex flow). With only one flex item and justify-content: space-between, the button fell back to flex-start (left). Fix: add margin-inline-start: auto to __close-button so it always pushes to the trailing edge — works for both the visible-title and hidden-title cases, and is RTL-safe via logical properties. Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]>
|
Visit https://backpack.github.io/storybook-prs/4962 to see this build running in a browser. |
| import themeAttributes from './src/themeAttributes'; | ||
|
|
||
| import type { Props } from './src/BpkDrawer'; | ||
| import type { SecondaryPanelProps } from './src/types'; |
There was a problem hiding this comment.
Unrelated TS error fix
…ast-child Refine the earlier fix: instead of margin-inline-start on __close-button only, apply it to the header's last child. This also covers the closeText (BpkLink) variant, so hideTitle + closeText together no longer collapses the control to the leading edge. margin-inline-start: auto is RTL-safe — resolves to right in LTR and left in RTL. Verified in Storybook across default, hideTitle, closeText, and RTL. Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]>
|
Visit https://backpack.github.io/storybook-prs/4962 to see this build running in a browser. |
| // Keep the close control at the trailing edge even when the title is | ||
| // visually hidden (out of flex flow) and only one flex item remains. | ||
| // Covers both the close-button and closeText (BpkLink) variants. | ||
| > :last-child { |
There was a problem hiding this comment.
target last child instead of just the close button class for the case where its a close text scenario and alternative class is used - this solves for all combos
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Fixes a regression where the drawer close control shifts to the leading edge when hideTitle removes the title from the flex flow, and exposes a missing public TypeScript type for secondary panel usage.
Changes:
- Pins the drawer header’s trailing control using
margin-inline-start: autoto keep it at the logical end in both LTR and RTL. - Exports
SecondaryPanelPropsfrom the package entrypoint to unblock consumers generating declaration files.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/backpack-web/src/bpk-component-drawer/src/BpkDrawerContent.module.scss | Ensures the header’s close control stays aligned to the trailing edge even when the title is visually hidden. |
| packages/backpack-web/src/bpk-component-drawer/index.ts | Re-exports SecondaryPanelProps so consumers can reference the type without deep imports. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Keep the close control at the trailing edge even when the title is | ||
| // visually hidden (out of flex flow) and only one flex item remains. | ||
| // Covers both the close-button and closeText (BpkLink) variants. | ||
| > :last-child { | ||
| margin-inline-start: auto; | ||
| } |
There was a problem hiding this comment.
This is a bit of a see-saw - if we add a specific class for the text button scenario and target 2 cases explicitly the future brittleness could be a 3rd case coming that misses adding it's own class. Either way is robus/fragile depending what the future holds so I'd lean on the simplicity of last-child but open to changing it if preference is to go the other way.
| import type { Props } from './src/BpkDrawer'; | ||
| import type { SecondaryPanelProps } from './src/types'; | ||
|
|
||
| export type BpkDrawerProps = Props; | ||
| export type { SecondaryPanelProps }; |
There was a problem hiding this comment.
This file already establishes the opposite pattern, deliberately. Line 24-27 does exactly the import-then-export dance for Props:
import type { Props } from './src/BpkDrawer';
export type BpkDrawerProps = Props;
So propose no change here.
Problem
Since 43.7.0, the drawer close control jumps to the top-left (LTR) instead of top-right whenever the title is visually hidden (
hideTitle). This blocks consumers bumping to ≥43.14.0 (IRN-6874).Root cause
PR #4848 (secondary panel, 43.7.0) removed an
from the drawer header. The header isdisplay: flex; justify-content: space-between, so it relied on two flex items (title + close) to push the close control to the trailing edge.When
hideTitleis set, the<h2>becomesposition: absolute(out of flex flow), leaving the close control as the only flex item — whichspace-betweenrenders atflex-start(left in LTR). The had silently been the second flex item holding the line. Its removal surfaced the regression.Before / After
hideTitle)Fix
BpkDrawerContent.module.scss— pin the header's last child to the trailing edge:__close-buttondiv and thecloseText<BpkLink>— sohideTitle+closeTexttogether also stays pinned.margin-inline-startis a logical property → RTL-safe with no direction-specific override (resolves to right in LTR, left in RTL).index.ts— also exportsSecondaryPanelProps(added toPropsin 43.7.0 but never surfaced publicly), fixing TS2742 in consumers that emit declaration files.Test plan
Verified in Storybook (
localhost:9001), drawer opened in each case:pnpm run typecheck— cleanpnpm jest bpk-component-drawer— 12/12 pass, 6 snapshots unchanged (HTML unaffected)🤖 Generated with Claude Code