Why is nesting `ScrollableColumn`s not allowed? My...
# compose
g
Why is nesting `ScrollableColumn`s not allowed? My use case: I’m making my own
TextField
component, and it internally needs a
ScrollableColumn
so that users can scroll when the text height is greater than the container size. Having an internal
ScrollableColumn
prevents me from putting this
TextField
in a screen with scrollable content (i.e. most screens)
Looking at the source code for Material
TextField
, they just built their own
ScrollableColumn
that doesn’t crash in this scenario?? 😄 Makes me feel like either Material is doing something bad, or
ScrollableColumn
is being too restrictive.
m
Nesting of
ScrollableColumn
is allowed and supported as far as I'm aware. The problem you see arising because ScrollableColumn measures its children with infinite constraints, so you have to limit your child
ScrollableColumn
to some height it order for it to work. Having said that, putting
ScrollableColumn
in
TextField
to scroll might solve your issue short term, but it's more complicated than that. You need to be able to scroll when cursor is dragged, you need to be able to auto-scroll down or up when line is added/removed, that's why we embed scrolling logic inside TextField. Since it's not a trivial task, in the upcoming releases we will port this logic to the
BasicTextField
as well, so any TextField you use will have this logic build-in, not only material 🙂 Let me know if you have any questions
g
Ah ok, this explains a lot, thank you for the in-depth reply! This is also fantastic news: porting it over to
BasicTextField
solves my main concern of having to maintain this code myself. Is there a public issue I can follow or anything? 👀
m
Here's the CL and there are two bugs linked in the commit message https://android-review.googlesource.com/c/platform/frameworks/support/+/1394667
❤️ 1