Fix long-form markdown editor scrolling and focus
Some checks failed
Dotnet build and test / build (push) Failing after 7m50s

This commit is contained in:
Paul Schneider 2026-10-04 20:18:43 +01:00
commit 1897a6807d
Signed by: notazof
GPG key ID: AD4B9B545FBD7D12

View file

@ -38,6 +38,8 @@ public partial class MarkdownEditorControl : UserControl
{
InitializeComponent();
PropertyChanged += OnPropertyChanged;
SizeChanged += OnSizeChanged;
UpdateEditorLimits();
}
private void OnPropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e)
@ -60,4 +62,27 @@ public partial class MarkdownEditorControl : UserControl
}
}
}
private void OnSizeChanged(object? sender, SizeChangedEventArgs e)
{
UpdateEditorLimits();
}
private void UpdateEditorLimits()
{
var visibleHeight = Bounds.Height > 0 ? Bounds.Height - 24 : 260;
visibleHeight = Math.Max(visibleHeight, 80);
if (SourceEditor is not null)
{
SourceEditor.MaxHeight = visibleHeight;
SourceEditor.Height = double.NaN;
}
if (PreviewViewer is not null)
{
PreviewViewer.MaxHeight = visibleHeight;
PreviewViewer.Height = double.NaN;
}
}
}