File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -1213,16 +1213,25 @@ and print_jsx cxt ?(spread_props : J.expression option)
12131213 | Some children ->
12141214 (* Tag with children *)
12151215 let has_children = List. length children > 0 in
1216- if has_multiple_props || has_children then P. newline f;
1216+ (* Newline for ">" only if props themselves were multi-line. Children alone don't push ">" to a new line. *)
1217+ if has_multiple_props then P. newline f;
12171218 P. string f " >" ;
12181219
12191220 let cxt_after_children =
1220- print_indented_list f level cxt children print_one_child
1221+ if has_children then
1222+ (* Only call print_indented_list if there are children *)
1223+ print_indented_list f level cxt children print_one_child
1224+ else cxt
1225+ (* No children, no change to context here, no newlines from children block *)
12211226 in
12221227 let cxt = cxt_after_children in
12231228
1224- P. newline f;
1225- (* For closing </tag> *)
1229+ (* The closing "</tag>" goes on a new line if the opening part was multi-line (due to props)
1230+ OR if there were actual children printed (which always makes the element multi-line).
1231+ *)
1232+ let element_content_was_multiline = has_multiple_props || has_children in
1233+ if element_content_was_multiline then P. newline f;
1234+
12261235 P. string f " </" ;
12271236 let cxt = print_tag cxt in
12281237 P. string f " >" ;
You can’t perform that action at this time.
0 commit comments