git.iko.soy/typeable/elm-ui
on master help sign in
resolves #130 - calculate heightContent correctly
4289046Matthew Griffith
src/Element/Input.elm+11−17
@@ -856,22 +856,6 @@ textHelper textInput attrs textOptions =
856 _ ->
856 _ ->
857 False
857 False
858
858
859− getHeight attr =
860− case attr of
861− Internal.Height h ->
862− Just h
863−
864− _ ->
865− Nothing
866−
867− isHeightContent attr =
868− case attr of
869− Internal.Height Internal.Content ->
870− True
871−
872− _ ->
873− False
874−
875 getPadding attr =
859 getPadding attr =
876 case attr of
860 case attr of
877 Internal.StyleClass cls (Internal.PaddingStyle pad t r b l) ->
861 Internal.StyleClass cls (Internal.PaddingStyle pad t r b l) ->
@@ -898,7 +882,7 @@ textHelper textInput attrs textOptions =
898 |> List.filterMap getHeight
882 |> List.filterMap getHeight
899 |> List.reverse
883 |> List.reverse
900 |> List.head
884 |> List.head
901− |> Maybe.map ((==) Internal.Content)
885+ |> Maybe.map isShrink
902 |> Maybe.withDefault False
886 |> Maybe.withDefault False
903
887
904 parentPadding =
888 parentPadding =
@@ -975,6 +959,7 @@ textHelper textInput attrs textOptions =
975 [ Element.width Element.fill
959 [ Element.width Element.fill
976 , Internal.htmlClass classes.focusedWithin
960 , Internal.htmlClass classes.focusedWithin
977 , Element.scrollbarY
961 , Element.scrollbarY
962+ , Internal.htmlClass classes.inputMultilineWrapper
978 ]
963 ]
979 )
964 )
980 ++ redistributed.parent
965 ++ redistributed.parent
@@ -1050,6 +1035,15 @@ textHelper textInput attrs textOptions =
1050 wrappedInput
1035 wrappedInput
1051
1036
1052
1037
1038+getHeight attr =
1039+ case attr of
1040+ Internal.Height h ->
1041+ Just h
1042+
1043+ _ ->
1044+ Nothing
1045+
1046+
1053negateBox box =
1047negateBox box =
1054 { top = negate box.top
1048 { top = negate box.top
1055 , right = negate box.right
1049 , right = negate box.right
src/Internal/Style.elm+16
@@ -255,6 +255,7 @@ classes =
255 , inputMultiline = "iml"
255 , inputMultiline = "iml"
256 , inputMultilineParent = "imlp"
256 , inputMultilineParent = "imlp"
257 , inputMultilineFiller = "imlf"
257 , inputMultilineFiller = "imlf"
258+ , inputMultilineWrapper = "implw"
258
259
259 -- link
260 -- link
260 , link = "lnk"
261 , link = "lnk"
@@ -1562,9 +1563,24 @@ baseSheet =
1562 , Prop "width" "100%"
1563 , Prop "width" "100%"
1563 , Prop "background-color" "transparent"
1564 , Prop "background-color" "transparent"
1564 ]
1565 ]
1566+ , Descriptor (dot classes.inputMultilineWrapper)
1567+ -- Get this.
1568+ -- This allows multiline input to anchor scrolling to the bottom of the node
1569+ -- when in a scrolling viewport, and the user is adding content.
1570+ --
1571+ -- How crazy is this solution?
1572+ -- [ Prop "display" "flex"
1573+ -- , Prop "flex-direction" "column-reverse"
1574+ -- ]
1575+ [ Descriptor "::after"
1576+ [ Prop "content" "''"
1577+ , Prop "overflow-anchor" "auto"
1578+ ]
1579+ ]
1565 , Descriptor (dot classes.inputMultilineParent)
1580 , Descriptor (dot classes.inputMultilineParent)
1566 [ Prop "white-space" "pre-wrap"
1581 [ Prop "white-space" "pre-wrap"
1567 , Prop "cursor" "text"
1582 , Prop "cursor" "text"
1583+ , Prop "overflow-anchor" "none"
1568 , Child (dot classes.inputMultilineFiller)
1584 , Child (dot classes.inputMultilineFiller)
1569 [ Prop "white-space" "pre-wrap"
1585 [ Prop "white-space" "pre-wrap"
1570 , Prop "color" "transparent"
1586 , Prop "color" "transparent"