@@ -856,6 +856,14 @@ textHelper textInput attrs textOptions =
856856 _ ->
857857 False
858858
859+ getHeight attr =
860+ case attr of
861+ Internal.Height h ->
862+ Just h
863+
864+ _ ->
865+ Nothing
866+
859867 isHeightContent attr =
860868 case attr of
861869 Internal.Height Internal.Content ->
@@ -864,16 +872,18 @@ textHelper textInput attrs textOptions =
864872 _ ->
865873 False
866874
867− bottomPadding attr =
875+ getPadding attr =
868876 case attr of
869877 Internal.StyleClass cls (Internal.PaddingStyle pad t r b l) ->
870− Just <|
871− Element.paddingEach
872− { top = 0
873− , right = 0
874− , bottom = b
875− , left = 0
876− }
878+ -- The - 3 is here to prevent accidental triggering of scrollbars
879+ -- when things are off by a pixel or two.
880+ -- (or at least when the browser *thinks* it's off by a pixel or two)
881+ Just
882+ { top = max 0 (floor (toFloat t - 3))
883+ , right = max 0 (floor (toFloat r - 3))
884+ , bottom = max 0 (floor (toFloat b - 3))
885+ , left = max 0 (floor (toFloat l - 3))
886+ }
877887
878888 _ ->
879889 Nothing
@@ -884,7 +894,24 @@ textHelper textInput attrs textOptions =
884894 False
885895
886896 TextArea ->
887− List.any isHeightContent withDefaults
897+ withDefaults
898+ |> List.filterMap getHeight
899+ |> List.reverse
900+ |> List.head
901+ |> Maybe.map ((==) Internal.Content)
902+ |> Maybe.withDefault False
903+
904+ parentPadding =
905+ withDefaults
906+ |> List.filterMap getPadding
907+ |> List.reverse
908+ |> List.head
909+ |> Maybe.withDefault
910+ { top = 0
911+ , right = 0
912+ , bottom = 0
913+ , left = 0
914+ }
888915
889916 inputElement =
890917 Internal.element
@@ -910,6 +937,9 @@ textHelper textInput attrs textOptions =
910937 , Element.height Element.fill
911938 , Internal.htmlClass classes.inputMultiline
912939 , calcMoveToCompensateForPadding withDefaults
940+ , Element.paddingEach parentPadding
941+ , Internal.Attr (Html.Attributes.style "margin" (renderBox (negateBox parentPadding)))
942+ , Internal.Attr (Html.Attributes.style "box-sizing" "content-box")
913943 ]
914944 )
915945 ++ [ value textOptions.text
@@ -932,10 +962,17 @@ textHelper textInput attrs textOptions =
932962 Internal.element
933963 Internal.asEl
934964 Internal.div
935− ([ Element.width Element.fill
936− , Element.scrollbarY
937− , Internal.htmlClass classes.focusedWithin
938− ]
965+ ((if heightContent then
966+ [ Element.width Element.fill
967+ , Internal.htmlClass classes.focusedWithin
968+ ]
969+
970+ else
971+ [ Element.width Element.fill
972+ , Internal.htmlClass classes.focusedWithin
973+ , Element.scrollbarY
974+ ]
975+ )
939976 ++ redistributed.parent
940977 )
941978 (Internal.Unkeyed
@@ -946,14 +983,7 @@ textHelper textInput attrs textOptions =
946983 :: Element.height Element.fill
947984 :: Element.inFront inputElement
948985 :: Internal.htmlClass classes.inputMultilineParent
949− :: List.concat
950− [ if heightContent then
951− redistributed.wrapper
952−
953− else
954− redistributed.wrapper
955− ++ List.filterMap bottomPadding redistributed.parent
956− ]
986+ :: redistributed.wrapper
957987 )
958988 (Internal.Unkeyed
959989 (if textOptions.text == "" then
@@ -1009,6 +1039,25 @@ textHelper textInput attrs textOptions =
10091039 wrappedInput
10101040
10111041
1042+negateBox box =
1043+ { top = negate box.top
1044+ , right = negate box.right
1045+ , bottom = negate box.bottom
1046+ , left = negate box.left
1047+ }
1048+
1049+
1050+renderBox { top, right, bottom, left } =
1051+ String.fromInt top
1052+ ++ "px "
1053+ ++ String.fromInt right
1054+ ++ "px "
1055+ ++ String.fromInt bottom
1056+ ++ "px "
1057+ ++ String.fromInt left
1058+ ++ "px"
1059+
1060+
10121061renderPlaceholder (Placeholder placeholderAttrs placeholderEl) forPlaceholder on =
10131062 Element.el
10141063 (forPlaceholder