| @@ -155,12 +155,25 @@ | ||
| 155 | 155 | /** |
| 156 | 156 | * @return bool |
| 157 | 157 | */ |
| 158 | 158 | private function should_first_close_the_active_field_wrapper() { |
| 159 | - if ( false === $this->parent_li || $this->section_helper ) { | |
| 159 | + if ( false === $this->parent_li ) { | |
| 160 | 160 | return false; |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | + /** | |
| 164 | + * Fields that sit inside an open section are wrapped by that section's own helper, so the | |
| 165 | + * row here is not theirs to close. set_field() opens the section helper for the section | |
| 166 | + * field itself, one step ahead of this check, and section_is_open is not set until | |
| 167 | + * sync_list_size() runs afterwards. Testing both is what keeps the section field subject to | |
| 168 | + * the width check below rather than being treated as though it were already inside itself. | |
| 169 | + * | |
| 170 | + * @see https://github.com/Strategy11/formidable-pro/issues/3820 | |
| 171 | + */ | |
| 172 | + if ( $this->section_helper && $this->section_is_open ) { | |
| 173 | + return false; | |
| 174 | + } | |
| 175 | + | |
| 163 | 176 | if ( 'end_divider' === $this->field->type ) { |
| 164 | 177 | return false; |
| 165 | 178 | } |
| 166 | 179 | |
| @@ -259,9 +272,14 @@ | ||
| 259 | 272 | /** |
| 260 | 273 | * @return void |
| 261 | 274 | */ |
| 262 | 275 | private function close_field_wrapper() { |
| 263 | - $this->maybe_close_section_helper(); | |
| 276 | + // Only an open section has a nested wrapper to close. A section helper that set_field() has | |
| 277 | + // just created belongs to the section about to start, so closing this row must leave it alone. | |
| 278 | + if ( $this->section_is_open ) { | |
| 279 | + $this->maybe_close_section_helper(); | |
| 280 | + } | |
| 281 | + | |
| 264 | 282 | echo '</ul></li>'; |
| 265 | 283 | $this->parent_li = false; |
| 266 | 284 | $this->current_list_size = 0; |
| 267 | 285 | $this->current_field_count = 0; |