Skip to content

Commit 4653a34

Browse files
fix text input layout bug
1 parent 3d82608 commit 4653a34

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

Sources/ComponentsKit/Components/TextInput/Models/TextInputVM.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ extension TextInputVM {
147147

148148
var maxTextInputHeight: CGFloat {
149149
if let maxRows {
150-
return self.height(forRows: maxRows)
150+
return self.height(forRows: max(maxRows, self.minRows))
151151
} else {
152152
return 10_000
153153
}

Sources/ComponentsKit/Components/TextInput/SUTextInput.swift

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,23 @@ public struct SUTextInput<FocusValue: Hashable>: View {
5555
TextEditor(text: self.$text)
5656
.contentMargins(self.model.contentPadding)
5757
.transparentScrollBackground()
58-
.frame(minHeight: self.model.minTextInputHeight)
59-
.frame(height: max(
60-
self.model.minTextInputHeight,
61-
min(
62-
self.model.maxTextInputHeight,
63-
self.textEditorPreferredHeight
58+
.frame(
59+
minHeight: self.model.minTextInputHeight,
60+
idealHeight: max(
61+
self.model.minTextInputHeight,
62+
min(
63+
self.model.maxTextInputHeight,
64+
self.textEditorPreferredHeight
65+
)
66+
),
67+
maxHeight: max(
68+
self.model.minTextInputHeight,
69+
min(
70+
self.model.maxTextInputHeight,
71+
self.textEditorPreferredHeight
72+
)
6473
)
65-
))
74+
)
6675
.lineSpacing(0)
6776
.font(self.model.preferredFont.font)
6877
.foregroundStyle(self.model.foregroundColor.color)

0 commit comments

Comments
 (0)