Fit a read-only table's rows to their cells
Some checks failed
Commit messages lint / commitlint (push) Has been cancelled
Some checks failed
Commit messages lint / commitlint (push) Has been cancelled
A table keeps each row's height on its cells, corrected after every layout through a transaction. A read-only editor applies no transaction (EditorState.apply returns while it isn't editable), so a table shown read-only kept the heights it was stored with, or the default of one line: a cell of several lines ran over its row's borders. The table's own height (colsHeight) already took the read-only case in place; the rows' heights now do the same. Upstream's main has the same code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MMm7usAo6q9ZZRoPkWjoxi
This commit is contained in:
parent
83bdb2a3e6
commit
81c3006c74
2 changed files with 26 additions and 0 deletions
|
|
@ -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},
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue