Box' gap not removed on wrapping
See original GitHub issueWhen 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:
With needless gap placed right-side next to box “Fifth” and box “Six” is centered as it should be:
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.
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:
- Created 10 months ago
- Comments:9 (6 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I understand the intent of the issue. Unfortunately, the current implementation of
gap
does not work withwrap
, 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 theoptions
property of Grommet: https://v2.grommet.io/grommet#options to support something likeoptions={{ box: { gap: 'css' } }}
.Awesome! I’m looking forward to the next release 😃