question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Box' gap not removed on wrapping

See original GitHub issue

When using Box with gap and wrap and justify="center" the StyledBoxGap is not removed on wrapping.

Expected Behavior

Gaps at wrapped lines have to be removed.

Actual Behavior

Gaps are not removed and appear as a left-margin in the next line and sometimes as a right-margin of the previous line (depending on the width of the content and the width of the window).

URL, screen shot, or Codepen exhibiting the issue

With this codesandbox all the problems can be reproduced: https://codesandbox.io/s/box-gap-wrap-issue-e9xgyl

Here also some screenshots to give you an idea:

With no needless gap because no wrapping is necessary: gap-wrap-issue1

With needless gap placed right-side next to box “Fifth” and box “Six” is centered as it should be: gap-wrap-issue2

With:

  • needless gap placed left-side next to box “Sixth” and boxes “Third” to “Fifth” are centered as it should be:
  • needless gap placed left-side next to box “First” because for sample 1 direction="row-reverse" is used. gap-wrap-issue3

Steps to Reproduce

Load the sandbox and resize the window the reproduce the problem.

Your Environment

  • Grommet version: 2.25.1
  • Browser Name and version: FireFox 107.0
  • Operating System and version (desktop or mobile): Ubuntu 22.04

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ericsoderberghpcommented, Nov 21, 2022

I understand the intent of the issue. Unfortunately, the current implementation of gap does not work with wrap, as is documented at https://v2.grommet.io/box#gap. A better approach would be to use https://developer.mozilla.org/en-US/docs/Web/CSS/gap, which came into being last year. It’s not as easy though as just changing the current Box implementation to use it as the CSS property applies to DOM elements while the current grommet Box approach applies to react children of the Box. When a Fragment is used for a child, react will expand the Fragment’s children when rendering in the DOM. So, it would not be backwards compatible to do a straight change. Instead, I think we need to find a way to let the caller opt-in to the new CSS method. On suggestion would be use the options property of Grommet: https://v2.grommet.io/grommet#options to support something like options={{ box: { gap: 'css' } }}.

0reactions
stephanpelikancommented, Nov 29, 2022

Awesome! I’m looking forward to the next release 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Remove space (gaps) between multiple lines of flex items ...
I am trying to achieve this using flexbox, a container with a set height, direction is set to column and flex-wrap is wrap...
Read more >
CSS Gap Space with Flexbox - Cory Rylan
CSS Flex Wrap and Margin Space. Margins works but is not the same behavior as CSS Gap space. Notice the extra space surrounding...
Read more >
Mastering wrapping of flex items - CSS: Cascading Style Sheets
It is this requirement that the gap properties, once implemented, will solve for us. Proper gaps only happen on the inside edges of...
Read more >
gap | CSS-Tricks
When the size of a container in the gap dimension is definite, gap resolves percentages against the size of the container's content box...
Read more >
Gap in flexbox & how to replicate it while we wait on Safari
The first 1000 people to use the link will get a free trial of Skillshare Premium Membership: https://skl.sh/kevinpowell11201Dive in deep ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found