Skip to content

Commit 7a3e4ac

Browse files
gegnepClaude Fable 5
andcommitted
fix(ui): measure MarkdownView with wrapped label sizes
MarkdownView only applied its wrap width to labels in doLayout, so measure reported single-line label sizes and a parent flex allocated too little height, overlapping sibling rows. Apply the wrap width from the measure constraints as well; doLayout still re-applies the final arranged width. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 00f3242 commit 7a3e4ac

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

src/ui/controls/markdown_view.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,22 @@ void MarkdownView::clear() {
427427
}
428428
}
429429

430+
LayoutSize MarkdownView::doMeasure(Renderer& renderer, const LayoutConstraints& constraints) {
431+
// Apply the wrap width before measuring: labels otherwise report single-line
432+
// sizes, the parent allocates too little height for the view, and sibling
433+
// rows overlap it. doLayout re-applies the final arranged width.
434+
float w = width();
435+
if (constraints.hasMaxWidth && constraints.maxWidth > 0.0f) {
436+
w = constraints.maxWidth;
437+
}
438+
if (w > 0.0f) {
439+
for (Label* label : m_wrappableLabels) {
440+
label->setMaxWidth(w);
441+
}
442+
}
443+
return Flex::doMeasure(renderer, constraints);
444+
}
445+
430446
void MarkdownView::doLayout(Renderer& renderer) {
431447
const float w = width();
432448
if (w > 0.0f) {

src/ui/controls/markdown_view.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class MarkdownView : public Flex {
1414
void trackWrappableLabel(Label* label) { m_wrappableLabels.push_back(label); }
1515

1616
protected:
17+
LayoutSize doMeasure(Renderer& renderer, const LayoutConstraints& constraints) override;
1718
void doLayout(Renderer& renderer) override;
1819

1920
private:

0 commit comments

Comments
 (0)