git.iko.soy/typeable/elm-ui
on master help sign in
resolves #130 - calculate heightContent correctly
commit428904691beebdf224617bfd1ba6ee645b6e5f11 authorMatthew Griffith <mdg.griffith@gmail.com> dateSat 27 Jul 2019, 17:49 (7 years ago) parentcd088cb
2 files changed+27−17
src/Element/Input.elm+11−17 src/Internal/Style.elm+16
src/Element/Input.elm+11−17
@@ -856,22 +856,6 @@ 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−
867− isHeightContent attr =
868− case attr of
869− Internal.Height Internal.Content ->
870− True
871−
872− _ ->
873− False
874−
875859 getPadding attr =
876860 case attr of
877861 Internal.StyleClass cls (Internal.PaddingStyle pad t r b l) ->
@@ -898,7 +882,7 @@ textHelper textInput attrs textOptions =
898882 |> List.filterMap getHeight
899883 |> List.reverse
900884 |> List.head
901− |> Maybe.map ((==) Internal.Content)
885+ |> Maybe.map isShrink
902886 |> Maybe.withDefault False
903887
904888 parentPadding =
@@ -975,6 +959,7 @@ textHelper textInput attrs textOptions =
975959 [ Element.width Element.fill
976960 , Internal.htmlClass classes.focusedWithin
977961 , Element.scrollbarY
962+ , Internal.htmlClass classes.inputMultilineWrapper
978963 ]
979964 )
980965 ++ redistributed.parent
@@ -1050,6 +1035,15 @@ textHelper textInput attrs textOptions =
10501035 wrappedInput
10511036
10521037
1038+getHeight attr =
1039+ case attr of
1040+ Internal.Height h ->
1041+ Just h
1042+
1043+ _ ->
1044+ Nothing
1045+
1046+
10531047negateBox box =
10541048 { top = negate box.top
10551049 , right = negate box.right
src/Internal/Style.elm+16
@@ -255,6 +255,7 @@ classes =
255255 , inputMultiline = "iml"
256256 , inputMultilineParent = "imlp"
257257 , inputMultilineFiller = "imlf"
258+ , inputMultilineWrapper = "implw"
258259
259260 -- link
260261 , link = "lnk"
@@ -1562,9 +1563,24 @@ baseSheet =
15621563 , Prop "width" "100%"
15631564 , Prop "background-color" "transparent"
15641565 ]
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+ ]
15651580 , Descriptor (dot classes.inputMultilineParent)
15661581 [ Prop "white-space" "pre-wrap"
15671582 , Prop "cursor" "text"
1583+ , Prop "overflow-anchor" "none"
15681584 , Child (dot classes.inputMultilineFiller)
15691585 [ Prop "white-space" "pre-wrap"
15701586 , Prop "color" "transparent"