pico icon indicating copy to clipboard operation
pico copied to clipboard

Grid with inputs has incorrect gap on mobile devices

Open ekerstein opened this issue 1 year ago • 3 comments

Describe the issue

Current Behavior

When a grid with inputs is viewed on a mobile device, the vertical spacing appears too wide and does not match with the same display of the non-grid version of the inputs.

Expected Behavior

Whether inputs are in a grid or not should not affect their vertical spacing on mobile devices.

Reproduction URL

  • Inputs inside of grid (view it on a mobile width): https://4mrnhq.csb.app/#:~:text=Range%20slider-,Valid,-Invalid
  • Inputs not inside of grid (view it on a mobile width): https://4mrnhq.csb.app/#:~:text=Search-,Text,-Curabitur%20consequat%20lacus

Images

Inputs inside of grid grid inputs

Inputs not inside of grid non-grid inputs

Grid gap for inputs on mobile grid input gap

Potential solution

The issue appears to be that grid-row-gap is applied on mobile widths to grids. Here's a potential solution that is working for me when I test it:

.grid {
    grid-row-gap: 0;
}
@media (min-width: 768px) {
    .grid {
        grid-row-gap: var(--pico-grid-row-gap);
    }
}

ekerstein avatar Feb 15 '24 22:02 ekerstein

@ekerstein, The grid-row-gap is helpful for elements other than form elements, like buttons. Also, because we have a --pico-grid-row-gap CSS var, it's easy for every website to tweak the behavior.

But I agree, the default behavior with input should be better because form elements are probably the most useful thing in Pico.

Maybe we could reset the margin-bottom for form elements on small screens: https://codepen.io/lucastests/pen/qBvvNdO

lucaslarroche avatar Feb 18 '24 04:02 lucaslarroche

@lucaslarroche Thank you for working on this, it's really appreciated.

Unfortunately, changing the margin didn't entirely fix the issue and has introduced two regressions that I was able to find. These issues didn't exist in 2.0.3.

I've created a codepen with examples: https://codepen.io/ekerstein/pen/RwONJKG

Small text overlaps input

image

No spacing between grids

Example 1:

image

Example 2 - Viewable on the example page

image

ekerstein avatar Mar 03 '24 09:03 ekerstein

@ekerstein thank you for the tests. For now I will simply revert my solution in a new patch. I will investigate later.

lucaslarroche avatar Mar 03 '24 10:03 lucaslarroche