mirror of
https://codeberg.org/secana/Forji.git
synced 2026-08-15 14:43:29 -07:00
fix: make code diffs reliably horizontally scrollable (#85)
Diff rows use maxWidth: .infinity inside a horizontal ScrollView, whose width proposal is unspecified. The resolution against a LazyVStack's cross-axis estimate was non-deterministic across devices: some scrolled, others collapsed to the viewport width and clipped long lines with no way to scroll. Give the content a definite intrinsic width via fixedSize so horizontal scrolling works on every device. Reviewed-on: https://codeberg.org/secana/Forji/pulls/88
This commit is contained in:
parent
3063eabfde
commit
3946db4f21
1 changed files with 7 additions and 0 deletions
|
|
@ -23,6 +23,12 @@ struct DiffView: View {
|
|||
|
||||
var body: some View {
|
||||
ScrollView(.horizontal) {
|
||||
// `.fixedSize(horizontal:)` gives the content a definite intrinsic
|
||||
// width (the widest line) inside the horizontal scroll view. Without
|
||||
// it, the rows' `maxWidth: .infinity` resolves ambiguously against the
|
||||
// scroll view's unspecified width proposal, so on some devices the
|
||||
// content collapses to the viewport width, clipping long lines with
|
||||
// nothing to scroll to instead of scrolling horizontally.
|
||||
LazyVStack(alignment: .leading, spacing: 0) {
|
||||
ForEach(Array(diff.files.enumerated()), id: \.offset) { fileIndex, file in
|
||||
let filePath = file.newName == "/dev/null" ? file.oldName : file.newName
|
||||
|
|
@ -57,6 +63,7 @@ struct DiffView: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
.fixedSize(horizontal: true, vertical: false)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue