diff --git a/tests/layout/test_flex.py b/tests/layout/test_flex.py
index 511bde633..6344b8f2a 100644
--- a/tests/layout/test_flex.py
+++ b/tests/layout/test_flex.py
@@ -576,3 +576,26 @@ def test_flex_percent_height_auto():
''')
+
+
+@assert_no_logs
+def test_flex_break_inside_avoid():
+ # Regression test for https://github.com/Kozea/WeasyPrint/issues/2183
+ page1, page2= render_pages('''
+
+
+ ABC
+ abc def
+ ''')
+ html, = page1.children
+ body, = html.children
+ article, = body.children
+ div, = article.children
+ html, = page2.children
+ body, = html.children
+ article, = body.children
+ div, = article.children
diff --git a/weasyprint/layout/flex.py b/weasyprint/layout/flex.py
index 5d3cef502..137906889 100644
--- a/weasyprint/layout/flex.py
+++ b/weasyprint/layout/flex.py
@@ -852,9 +852,12 @@ def flex_layout(context, box, bottom_space, skip_stack, containing_block,
if new_child is None:
if resume_at:
index, = resume_at
- if index:
- resume_at = {index + i - 1: None}
+ index -= 1
+ else:
+ index = 0
+ resume_at = {index + i: None}
else:
+ page_is_empty = False
box.children.append(new_child)
if child_resume_at is not None:
if original_skip_stack: