Skip to content

[BD-9759][BpkPopover] Add close button beside body #3883

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 17, 2025

Conversation

karlahuang
Copy link
Contributor

@karlahuang karlahuang commented Jul 15, 2025

We found close icon button always be with title together. But sometimes we need the button while no title, so need to handle this case in codes.

Remember to include the following changes:

  • Ensure the PR title includes the name of the component you are changing so it's clear in the release notes for consumers of the changes in the version e.g [Clover-123][BpkButton] Updating the colour
  • README.md (If you have created a new component)
  • Component README.md
  • Tests
  • Accessibility tests
    • The following checks were performed:
      • Ability to navigate using a keyboard only
      • Zoom functionality (Deque University explanation):
        • The page SHOULD be functional AND readable when only the text is magnified to 200% of its initial size
        • Pages must reflow as zoom increases up to 400% so that content continues to be presented in only one column i.e. Content MUST NOT require scrolling in two directions (both vertically and horizontally)
      • Ability to navigate using a screen reader only
  • Storybook examples created/updated
  • For breaking changes or deprecating components/properties, migration guides added to the description of the PR. If the guide has large changes, consider creating a new Markdown page inside the component's docs folder and link it here

@karlahuang karlahuang changed the title [BD-9759] Add close button beside BpkPopover body [BD-9759][BpkPopover] Add close button beside body Jul 15, 2025
@karlahuang karlahuang added the patch Patch production bug label Jul 15, 2025
@skyscanner-backpack-bot
Copy link

Visit https://backpack.github.io/storybook-prs/3883 to see this build running in a browser.

@skyscanner-backpack-bot
Copy link

skyscanner-backpack-bot bot commented Jul 15, 2025

Warnings
⚠️

Package source files (e.g. packages/package-name/src/Component.js) were updated, but snapshots weren't. Have you checked that the tests still pass?

Browser support

If this is a visual change, make sure you've tested it in multiple browsers.

Generated by 🚫 dangerJS against 55f0fd6

<div className={bodyClassNames}>
<div>{children}</div>
{!labelAsTitle && closeButtonIcon && (
<BpkCloseButton
Copy link
Contributor

Choose a reason for hiding this comment

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

In the code above we also define a closebutton, can we ensure both close buttons us the same code (ie. refactor to a const)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, it's the same code, let me do some refactoring. Thank you

@skyscanner-backpack-bot
Copy link

Visit https://backpack.github.io/storybook-prs/3883 to see this build running in a browser.

Co-authored-by: tuxiu.luo <359703836@qq.com>
@skyscanner-backpack-bot
Copy link

Visit https://backpack.github.io/storybook-prs/3883 to see this build running in a browser.

Copy link
Contributor

@LuoTuxiu LuoTuxiu left a comment

Choose a reason for hiding this comment

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

LGTM

@Faye-Xiao Faye-Xiao requested a review from Copilot July 16, 2025 10:35
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements the ability to display a close button in the popover body when there's no title, addressing the case where a close icon button is needed without a title being present. The change allows for more flexible popover configurations while maintaining existing functionality.

  • Extracts close button elements into reusable components for better code organization
  • Adds conditional rendering of close button icon in popover body when labelAsTitle is false
  • Updates CSS to support flexbox layout for proper positioning of close button beside body content

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
BpkPopover.tsx Refactors close button rendering logic and adds close button to body when no title is present
BpkPopover.module.scss Adds flexbox styling to popover body for close button positioning
BpkPopover-test.tsx Adds test coverage for new close button functionality and fixes code style issues
stories.js Exports new story example for popover without title
examples.js Implements example component demonstrating popover without title functionality

@@ -300,7 +295,10 @@ const BpkPopover = ({
{label}
</span>
)}
<div className={bodyClassNames}>{children}</div>
<div className={bodyClassNames}>
<div>{children}</div>
Copy link
Preview

Copilot AI Jul 16, 2025

Choose a reason for hiding this comment

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

Wrapping children in an anonymous div without any styling or semantic purpose adds unnecessary DOM nesting. Consider removing this wrapper div or adding appropriate CSS classes if styling is needed.

Suggested change
<div>{children}</div>
{children}

Copilot uses AI. Check for mistakes.

Copy link
Contributor

Choose a reason for hiding this comment

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

🤔 Why do we need a nested DIV here? Any specific consideration?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just keep the original layout, previous children is also wrapped with div. Maybe because children could be some pure strings

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if I find the right place. I noticed the children is a ReactNode prop. I didn't see any wrapped div.
Is this the previous code?

<div className={bodyClassNames}>{children}</div>
{actionText && onAction && (
<div className={getClassName('bpk-popover__action')}>
<BpkButtonLink onClick={onAction}>
{actionText}
</BpkButtonLink>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, I mean this line <div className={bodyClassNames}>{children}</div> , it would keep the layout of children

Copy link
Contributor

Choose a reason for hiding this comment

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

I closely examined the storybook case and discovered that the reason an inner DIV is necessary is due to the new class name, bpk-popover__body, which uses a flex layout. This layout requires a DIV to wrap the child elements; without it, the layout will not function correctly.

Screenshot 2025-07-17 at 15 37 00

@Faye-Xiao Faye-Xiao added minor Non breaking change and removed patch Patch production bug labels Jul 16, 2025
@skyscanner-backpack-bot
Copy link

Visit https://backpack.github.io/storybook-prs/3883 to see this build running in a browser.

@Faye-Xiao Faye-Xiao merged commit 84a880a into main Jul 17, 2025
10 checks passed
@Faye-Xiao Faye-Xiao deleted the BD-9759-Add-close-button-beside-BpkPopover-body branch July 17, 2025 11:56
Supremeyh added a commit that referenced this pull request Jul 28, 2025
Supremeyh added a commit that referenced this pull request Jul 28, 2025
karlahuang added a commit that referenced this pull request Jul 28, 2025
gert-janvercauteren added a commit that referenced this pull request Jul 31, 2025
* main:
  [QUAR-991] [BpkInsetBannerSponsored] Add closeOnScrimClick prop to BpkBottomSheet (#3891)
  Revert "[BD-9759][BpkPopover] Add close button beside body (#3883)" (#3894)
  optimize cardlist style (#3893)
  [CLOV-402][BpkCardList] Fix cardlist initially shown cards change issue (#3892)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor Non breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants