When using Compose for Web, how do you deal with t...
# compose-web
c
When using Compose for Web, how do you deal with text selection? I think on the web users expect to be able to select the entire page. But I don’t know if wrapping the whole page within a
SelectionContainer
is a good idea. The alternative is to create a custom
Text
component that wraps every label inside a
SelectionContainer
, which also does not seem appealing. Is there an approach between the 2 extremes?
o
if wrapping the whole page within a
SelectionContainer
is a good idea.
It might affect your app’s performance.
The alternative is to create a custom
Text
component that wraps every label inside a
SelectionContainer
It’s not so bad as the first option. Still, I’d add the SelectionContainer only where it’s necessary. Where would your users want to select the text and copy it? For example, you almost never want to copy the App Toolbar text or a text in a button. If it’s a short text which is supposed to be copied quite often, I’d add a copy button near the text to improve the UX. By default, on Android all texts are not selectable. You can make them selectable when necessary - depending on a use case. Apply the same approach here.
c
My specific case right now is a data table for an internal dashboard. Maybe I should just wrap the table in a SelectionContainer.
👍 1
j
@Oleksandr Karpovich [JB] in ^ that example, is there a difference in wrapping a whole table or each cell individually?
o
Yes. When you wrap a whole table you will able to select many cells in one selection gesture.
j
Right, of course, I was thinking more about performance-wise
o
good question: The composition and recomposition of every cell will get heavier when individual cells are wrapped in a SelectionContainer. I’d measure both variants. But intuitively in this case it makes sense to wrap the table.
👍 1