@@ -82,16 +82,19 @@ export const FormLayoutMixin = (superClass) =>
82
82
} ,
83
83
84
84
/**
85
- * When enabled, the layout automatically creates and adjusts columns based on
86
- * the container's width. Columns have a fixed width defined by `columnWidth`
87
- * and their number increases up to the limit set by `maxColumns`. The layout
88
- * dynamically adjusts the number of columns as the container size changes.
85
+ * Enables the auto responsive mode where the component automatically creates and adjusts
86
+ * columns based on the container's width. Columns have a fixed width defined by `columnWidth`
87
+ * and their number increases up to the limit set by `maxColumns`. The component dynamically
88
+ * adjusts the number of columns as the container size changes. When this mode is enabled,
89
+ * the `responsiveSteps` are ignored.
89
90
*
90
- * By default, each field is placed on a new row. To group fields in the same row,
91
- * wrap them in `<vaadin-form-row>` or enable the `autoRows` property, which allows
92
- * the layout to fit as many fields as possible in a row before wrapping.
91
+ * By default, each field is placed on a new row. To organize fields into rows, there are
92
+ * two options:
93
93
*
94
- * NOTE: In this mode, `responsiveSteps` are ignored.
94
+ * 1. Use `<vaadin-form-row>` to explicitly group fields into rows.
95
+ *
96
+ * 2. Enable the `autoRows` property to automatically arrange fields in available columns,
97
+ * wrapping to a new row when necessary. `<br>` elements can be used to force a new row.
95
98
*
96
99
* @attr {boolean} auto-responsive
97
100
*/
@@ -118,7 +121,7 @@ export const FormLayoutMixin = (superClass) =>
118
121
/**
119
122
* When `autoResponsive` is enabled, defines the maximum number of columns
120
123
* that the layout can create. The layout will create columns up to this
121
- * limit based on the available container width.
124
+ * limit based on the available container width. The default value is `10`.
122
125
*
123
126
* @attr {number} max-columns
124
127
*/
@@ -131,7 +134,8 @@ export const FormLayoutMixin = (superClass) =>
131
134
/**
132
135
* When enabled with `autoResponsive`, distributes fields across columns
133
136
* by placing each field in the next available column and wrapping to
134
- * the next row when the current row is full.
137
+ * the next row when the current row is full. `<br>` elements can be
138
+ * used to force a new row.
135
139
*
136
140
* @attr {boolean} auto-rows
137
141
*/
@@ -299,6 +303,7 @@ export const FormLayoutMixin = (superClass) =>
299
303
}
300
304
301
305
if ( this . autoResponsive ) {
306
+ this . __updateCSSGridLayout ( ) ;
302
307
return ;
303
308
}
304
309
@@ -385,6 +390,31 @@ export const FormLayoutMixin = (superClass) =>
385
390
} ) ;
386
391
}
387
392
393
+ /** @private */
394
+ __updateCSSGridLayout ( ) {
395
+ let resetColumn = false ;
396
+
397
+ [ ...this . children ]
398
+ . flatMap ( ( child ) => {
399
+ return child . localName === 'vaadin-form-row' ? [ ...child . children ] : child ;
400
+ } )
401
+ . forEach ( ( child ) => {
402
+ const { parentElement } = child ;
403
+
404
+ if ( child . localName === 'br' || parentElement . localName === 'vaadin-form-row' ) {
405
+ resetColumn = true ;
406
+ return ;
407
+ }
408
+
409
+ if ( resetColumn && ! isElementHidden ( child ) && parentElement . localName !== 'vaadin-form-row' ) {
410
+ child . style . setProperty ( '--_column-start' , 1 ) ;
411
+ resetColumn = false ;
412
+ } else {
413
+ child . style . removeProperty ( '--_column-start' ) ;
414
+ }
415
+ } ) ;
416
+ }
417
+
388
418
/**
389
419
* @protected
390
420
* @override
0 commit comments