Skip to content

Commit 3e80bb4

Browse files
authored
Forms: horizontal button align (#45188)
* better alignment for buttons sharing space with fields * changelog * use min-height so to allow buttons to grow with wrapping text and line jumps * allow flex grow/shrink on form blocks to allow better layout handling * match min-height and width when __link is on a row stack, doesn't affect the actual width which is handled by its wrapper
1 parent cbcf4d4 commit 3e80bb4

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: fixed
3+
4+
Forms: improve button alignment when field width allows wrapping the submit button

projects/packages/forms/src/blocks/contact-form/editor.scss

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,28 @@
5555
}
5656

5757
.wp-block {
58-
flex: 0 0 100%;
58+
flex: 1 1 100%;
5959
margin-top: 0;
6060
margin-bottom: 0;
6161
max-width: 100%;
6262

6363
&.wp-block-jetpack-button {
6464
flex-basis: auto;
65+
min-height: var(--jetpack--contact-form--input-height, auto);
66+
align-self: flex-end;
67+
line-height: 1;
68+
69+
.wp-block-button__link {
70+
min-height: var(--jetpack--contact-form--input-height, auto);
71+
}
72+
}
73+
74+
&.wp-block-group-is-layout-flex:not(.is-vertical) {
75+
// when the button is on a row stack, we expect it to fill the width of the
76+
// button block container (which is filling the provided column width)
77+
.wp-block.wp-block-jetpack-button .wp-block-button__link {
78+
width: 100%;
79+
}
6580
}
6681

6782
&.jetpack-field__width-25,

projects/packages/forms/src/contact-form/css/grunion.scss

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,14 @@ that needs to mimic the input element styles */
346346
}
347347

348348
.wp-block-jetpack-contact-form .wp-block-jetpack-button {
349-
width: fit-content;
349+
min-height: var(--jetpack--contact-form--input-height, auto);
350+
align-self: flex-end;
351+
352+
.wp-block-button__link {
353+
min-height: var(--jetpack--contact-form--input-height, auto);
354+
padding: var(--jetpack--contact-form--input-padding);
355+
}
356+
350357
}
351358

352359
.wp-block-jetpack-contact-form .wp-block-jetpack-button.aligncenter {
@@ -371,6 +378,7 @@ that needs to mimic the input element styles */
371378
.wp-block-jetpack-contact-form .grunion-field-wrap {
372379
box-sizing: border-box;
373380
position: relative;
381+
flex: 1 1 100%;
374382
}
375383

376384
.wp-block-jetpack-contact-form .grunion-field-width-25-wrap {

0 commit comments

Comments
 (0)