From 8615dffe3e786472141abf3dae8df38662bb6099 Mon Sep 17 00:00:00 2001 From: Angelo Silvestre Date: Sat, 19 Oct 2024 02:08:11 -0300 Subject: [PATCH] [SuperTextField] Fix golden failure (Resolves #2343) (#2352) --- super_editor/pubspec.yaml | 10 +++++----- super_text_layout/lib/src/super_text.dart | 8 +++++++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/super_editor/pubspec.yaml b/super_editor/pubspec.yaml index 712ba40a2d..5651e68a31 100644 --- a/super_editor/pubspec.yaml +++ b/super_editor/pubspec.yaml @@ -47,13 +47,13 @@ dependencies: flutter_test_robots: ^0.0.24 clock: ^1.1.1 -#dependency_overrides: +dependency_overrides: # Override to local mono-repo path so devs can test this repo # against changes that they're making to other mono-repo packages -# attributed_text: -# path: ../attributed_text -# super_text_layout: -# path: ../super_text_layout + # attributed_text: + # path: ../attributed_text + super_text_layout: + path: ../super_text_layout dev_dependencies: flutter_lints: ^2.0.1 diff --git a/super_text_layout/lib/src/super_text.dart b/super_text_layout/lib/src/super_text.dart index 78fdec61a6..34c4ba9285 100644 --- a/super_text_layout/lib/src/super_text.dart +++ b/super_text_layout/lib/src/super_text.dart @@ -429,7 +429,13 @@ class RenderLayoutAwareParagraph extends RenderParagraph { ..textDirection = textDirection ..textAlign = textAlign ..layout(); - size = Size(size.width, _textPainter.height); + + // We have no text, so we set the height of this render object to the line height + // of an arbitrary character of the given style. However, it's possible that our + // parent render object imposed constraints that are shorter than a single line + // of text. To avoid breaking Flutter's layout rules, we take the minimum height + // between the single line of text, and the incoming height constraints. + size = constraints.constrain(Size(size.width, _textPainter.height)); } } }