Skip to content

Comments

Fix bds-grid gap alignment issue with child grid elements#1059

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-1058
Draft

Fix bds-grid gap alignment issue with child grid elements#1059
Copilot wants to merge 3 commits intomainfrom
copilot/fix-1058

Conversation

Copy link
Contributor

Copilot AI commented Jun 24, 2025

Problem

When using the bds-grid component with the gap attribute, child grid elements lose alignment with the container's outer edges. This causes cards to visually shift inward and break the expected layout due to double spacing from both CSS gap and horizontal padding.

Before (broken):

<bds-grid direction="row" gap="1">
  <bds-grid md="4" sm="4">Card 1</bds-grid>
  <bds-grid md="4" sm="4">Card 2</bds-grid>
  <bds-grid md="4" sm="4">Card 3</bds-grid>
</bds-grid>

Results in misaligned cards that don't touch the container edges.

Required workaround (manual fix):

<bds-grid direction="row" gap="1">
  <bds-grid md="4" sm="4" padding="l-none">Card 1</bds-grid>
  <bds-grid md="4" sm="4" padding="x-none">Card 2</bds-grid>
  <bds-grid md="4" sm="4" padding="r-none">Card 3</bds-grid>
</bds-grid>

Solution

Added a simple CSS rule in src/global-style.scss that automatically removes horizontal padding from child bds-grid elements when their parent has a gap attribute:

// Fix for grid gap alignment issue
// When a bds-grid has gap attribute, remove horizontal padding from child bds-grid elements
bds-grid[gap] bds-grid {
  padding-left: 0 !important;
  padding-right: 0 !important;
}

Benefits

  • No manual workarounds needed - Users can now simply use gap without padding adjustments
  • Works with all gap values - none, half, 1-12 all work correctly
  • Backward compatible - No existing functionality is broken
  • Minimal, surgical fix - Single CSS rule solves the core issue
  • All tests pass - Comprehensive test coverage validates the solution

Testing

  • Added new unit tests for gap functionality with child grids
  • Added Storybook story demonstrating the fix (gapGridFixed)
  • Verified all existing tests continue to pass (3,226 tests passed)
  • Confirmed build succeeds without issues

After this fix:

<bds-grid direction="row" gap="1">
  <bds-grid md="4" sm="4">Card 1</bds-grid>
  <bds-grid md="4" sm="4">Card 2</bds-grid>
  <bds-grid md="4" sm="4">Card 3</bds-grid>
</bds-grid>

Now works perfectly with proper alignment! 🎉

Fixes #1058.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • example.com
    • Triggering command: /home/REDACTED/work/blip-ds/blip-ds/node_modules/puppeteer/.local-chromium/linux-1002410/chrome-linux/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --no-sandbox --disable-dev-shm-usage --use-angle=swiftshader-webgl --use-gl=angle --mute-audio --headless --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,2213203103363940568,11278762149898707617,131072 --enable-features=NetworkServiceInProcess2 --disable-features=AvoidUnnecessaryBeforeUnloadCheckSync,BackForwardCache,PaintHolding,Translate (dns block)
    • Triggering command: /home/REDACTED/work/blip-ds/blip-ds/node_modules/puppeteer/.local-chromium/linux-1002410/chrome-linux/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --no-sandbox --disable-dev-shm-usage --use-angle=swiftshader-webgl --use-gl=angle --mute-audio --headless --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,17762543706280341618,2342039746979405842,131072 --enable-features=NetworkServiceInProcess2 --disable-features=AvoidUnnecessaryBeforeUnloadCheckSync,BackForwardCache,PaintHolding,Translate (dns block)
    • Triggering command: /home/REDACTED/work/blip-ds/blip-ds/node_modules/puppeteer/.local-chromium/linux-1002410/chrome-linux/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --no-sandbox --disable-dev-shm-usage --use-angle=swiftshader-webgl --use-gl=angle --mute-audio --headless --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,8806340739362283785,11416177663928639231,131072 --enable-features=NetworkServiceInProcess2 --disable-features=AvoidUnnecessaryBeforeUnloadCheckSync,BackForwardCache,PaintHolding,Translate (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: lucasoares <10624972+lucasoares@users.noreply.github.com>
@cyber-sast
Copy link

cyber-sast commented Jun 24, 2025

Logo
Checkmarx One – Scan Summary & Details344a733b-d3c4-4973-832e-1c71821c40af

Great job, no security vulnerabilities found in this Pull Request

Co-authored-by: lucasoares <10624972+lucasoares@users.noreply.github.com>
Copilot AI changed the title [WIP] bds-grid breaks child layout alignment when using gap on the container Fix bds-grid gap alignment issue with child grid elements Jun 24, 2025
Copilot AI requested a review from lucasoares June 24, 2025 19:56
Copilot AI temporarily deployed to storybook-preview June 25, 2025 02:11 Inactive
@github-actions
Copy link

PR Preview Action v1.6.1

🚀 View preview at
https://takenet.github.io/blip-ds/pr-preview/pr-1059/

Built to branch gh-pages at 2025-06-25 02:13 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

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.

bds-grid breaks child layout alignment when using gap on the container

3 participants