Skip to content
This repository was archived by the owner on Aug 5, 2026. It is now read-only.

[IRN-6874][BpkDrawer] Fix close button position regression when hideTitle is set - #4962

Merged
Iris Li (wpe1arhy) merged 3 commits into
mainfrom
irn-6874-bpkdrawer-export-secondary-panel-props
Jul 24, 2026
Merged

Iris Li (wpe1arhy) merged 3 commits into
mainfrom
irn-6874-bpkdrawer-export-secondary-panel-props

Conversation

@steviehailey-skyscanner

@steviehailey-skyscanner Stephen Hailey (steviehailey-skyscanner) commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

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 is display: flex; justify-content: space-between, so it relied on two flex items (title + close) to push the close control to the trailing edge.

When hideTitle is set, the <h2> becomes position: absolute (out of flex flow), leaving the close control as the only flex item — which space-between renders at flex-start (left in LTR). The &nbsp; had silently been the second flex item holding the line. Its removal surfaced the regression.

Before / After

Close control position
Before (43.7.0–43.15.0, hideTitle) ❌ top-left
After ✅ top-right (LTR) / top-left = trailing (RTL)

Fix

BpkDrawerContent.module.scss — pin the header's last child to the trailing edge:

&__header {
  ...
  > :last-child {
    margin-inline-start: auto;
  }
}
  • Covers both close variants — the __close-button div and the closeText <BpkLink> — so hideTitle + closeText together also stays pinned.
  • margin-inline-start is a logical property → RTL-safe with no direction-specific override (resolves to right in LTR, left in RTL).

index.ts — also exports SecondaryPanelProps (added to Props in 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:

  • Default (visible title + ✕) — title left, ✕ right ✓
  • With Visually Hidden Title (✕ only) — ✕ right ✓
  • Close Button Text (title + "Done" link) — title left, link right ✓
  • RTL + hidden title — drawer mirrors left, ✕ at trailing edge ✓
  • pnpm run typecheck — clean
  • pnpm jest bpk-component-drawer — 12/12 pass, 6 snapshots unchanged (HTML unaffected)

🤖 Generated with Claude Code

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]>
@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

…eTitle is set

PR #4848 removed the `&nbsp;` 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]>
@steviehailey-skyscanner Stephen Hailey (steviehailey-skyscanner) changed the title [IRN-6874][BpkDrawer] Export SecondaryPanelProps from public index [IRN-6874][BpkDrawer] Fix close button position regression when hideTitle is set Jul 23, 2026
@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

import themeAttributes from './src/themeAttributes';

import type { Props } from './src/BpkDrawer';
import type { SecondaryPanelProps } from './src/types';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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]>
@steviehailey-skyscanner
Stephen Hailey (steviehailey-skyscanner) marked this pull request as ready for review July 23, 2026 13:29
Copilot AI review requested due to automatic review settings July 23, 2026 13:29
@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

// 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 {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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: auto to keep it at the logical end in both LTR and RTL.
  • Exports SecondaryPanelProps from 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.

Comment on lines +85 to +90
// 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;
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Comment on lines 24 to +28
import type { Props } from './src/BpkDrawer';
import type { SecondaryPanelProps } from './src/types';

export type BpkDrawerProps = Props;
export type { SecondaryPanelProps };

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

@wpe1arhy Iris Li (wpe1arhy) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@wpe1arhy
Iris Li (wpe1arhy) merged commit f3622d8 into main Jul 24, 2026
15 of 17 checks passed
@wpe1arhy
Iris Li (wpe1arhy) deleted the irn-6874-bpkdrawer-export-secondary-panel-props branch July 24, 2026 02:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

patch Patch production bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants