From 19cbe6910e190a5218fbad18a08077d4e2eaaf7d Mon Sep 17 00:00:00 2001 From: KrLite Date: Wed, 18 Dec 2024 20:13:34 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20`LuminareTextEditor`=20wro?= =?UTF-8?q?ngly=20consumed=20space?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sources/Luminare/Components/LuminareTextEditor.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Sources/Luminare/Components/LuminareTextEditor.swift b/Sources/Luminare/Components/LuminareTextEditor.swift index c601aec..de6bf44 100644 --- a/Sources/Luminare/Components/LuminareTextEditor.swift +++ b/Sources/Luminare/Components/LuminareTextEditor.swift @@ -15,6 +15,7 @@ public struct LuminareTextEditor: View { @Environment(\.isEnabled) private var isEnabled @Environment(\.font) private var font @Environment(\.luminareAnimationFast) private var animationFast + @Environment(\.luminareMinHeight) private var minHeight @Environment(\.luminareHorizontalPadding) private var horizontalPadding // MARK: Fields @@ -23,6 +24,7 @@ public struct LuminareTextEditor: View { @Binding private var selection: Any? // Handle os versions below macOS 15.0 @State private var isHovering: Bool = false + @State private var containerSize: CGSize = .zero // MARK: Initializers @@ -65,15 +67,21 @@ public struct LuminareTextEditor: View { TextEditor(text: $text) } } - .fixedSize(horizontal: false, vertical: true) + .scrollDisabled(true) .padding(.horizontal, horizontalPadding) .padding(.vertical, 14) + .frame(minHeight: max(minHeight, containerSize.height)) } .scrollContentBackground(.hidden) .font(font ?? .body) .modifier(LuminareHoverable()) .luminareAspectRatio(unapplying: true) .luminareHorizontalPadding(0) + .onGeometryChange(for: CGSize.self) { proxy in + proxy.size + } action: { newValue in + containerSize = newValue + } } @available(macOS 15.0, *)