diff --git a/lib/src/editor/block_component/table_block_component/table_node.dart b/lib/src/editor/block_component/table_block_component/table_node.dart index 718abaf5..10563916 100644 --- a/lib/src/editor/block_component/table_block_component/table_node.dart +++ b/lib/src/editor/block_component/table_block_component/table_node.dart @@ -209,6 +209,14 @@ class TableNode { _cells[i][row], {TableCellBlockKeys.height: maxHeight}, ); + // A read-only editor applies no transaction, so its rows would + // keep their height whatever their cells hold: they take it in + // place, as the table's height below does. + if (editorState != null && editorState.editable != true) { + _cells[i][row].updateAttributes( + {TableCellBlockKeys.height: maxHeight}, + ); + } } else { _cells[i][row].updateAttributes( {TableCellBlockKeys.height: maxHeight}, diff --git a/test/new/block_component/table_block_component/table_view_test.dart b/test/new/block_component/table_block_component/table_view_test.dart index 9e4815ee..f1a86d9d 100644 --- a/test/new/block_component/table_block_component/table_view_test.dart +++ b/test/new/block_component/table_block_component/table_view_test.dart @@ -83,5 +83,23 @@ void main() async { expect(tableNode.getRowHeight(0), row0beforeHeight); await editor.dispose(); }); + + testWidgets('a read-only table fits its rows to their cells', ( + tester, + ) async { + final tableNode = TableNode.fromList([ + ['one\ntwo\nthree', ''], + ['', ''], + ]); + final editor = tester.editor..addNode(tableNode.node); + + await editor.startTesting(editable: false); + await tester.pumpAndSettle(); + + final cell00 = getCellNode(tableNode.node, 0, 0)!; + expect(tableNode.getRowHeight(0), cell00.children.first.rect.height + 8); + expect(tableNode.getRowHeight(0), greaterThan(tableNode.getRowHeight(1))); + await editor.dispose(); + }); }); }