Description
When paragraphs inside table cells have the "Keep with next" paragraph setting enabled (Line & Page Breaks > Keep with next), the table still splits across page breaks. The same document in MS Word correctly keeps the rows together on the same page.
Steps to reproduce
- Create a new document
- Add text to fill most of page 1
- Insert a table with 3-4 rows below the text
- Select all cells in the first row
- Open Paragraph > Advanced Settings > Line & Page Breaks
- Check "Keep with next"
- Observe: the table is split across pages (first row on page 1, remaining rows on page 2)
Expected behavior
The entire table should move to page 2, keeping all rows together — matching MS Word behavior.
Actual behavior
The table splits across the page break despite "Keep with next" being set.
Root cause
RecalculateKeepNext() in DocumentContentElementBase.js (line 292) returns early when this.Parent is not CDocument. Since paragraphs inside table cells have CDocumentContent as their parent, KeepNext is never evaluated for paragraphs within table cells. The table layout engine in TableRecalculate.js has no logic to check KeepNext on cell paragraphs when deciding where to split rows across pages.
Proposed fix
Added KeepNext backtracking in the table page-break logic in TableRecalculate.js. After determining which row triggers a page break, walk backward and also move rows whose last cell paragraph has KeepNext set. Includes an infinite-loop guard for when the table is the first element on the page.
See PR: ONLYOFFICE/sdkjs#4870
Description
When paragraphs inside table cells have the "Keep with next" paragraph setting enabled (Line & Page Breaks > Keep with next), the table still splits across page breaks. The same document in MS Word correctly keeps the rows together on the same page.
Steps to reproduce
Expected behavior
The entire table should move to page 2, keeping all rows together — matching MS Word behavior.
Actual behavior
The table splits across the page break despite "Keep with next" being set.
Root cause
RecalculateKeepNext()inDocumentContentElementBase.js(line 292) returns early whenthis.Parentis notCDocument. Since paragraphs inside table cells haveCDocumentContentas their parent, KeepNext is never evaluated for paragraphs within table cells. The table layout engine inTableRecalculate.jshas no logic to check KeepNext on cell paragraphs when deciding where to split rows across pages.Proposed fix
Added KeepNext backtracking in the table page-break logic in
TableRecalculate.js. After determining which row triggers a page break, walk backward and also move rows whose last cell paragraph has KeepNext set. Includes an infinite-loop guard for when the table is the first element on the page.See PR: ONLYOFFICE/sdkjs#4870