Is there a good way to hide or prevent the selecti...
# compose
j
Is there a good way to hide or prevent the selection dropper icon from displaying in a TextField? More details in thread.
3
The orange icon is what I'm referring to
I’m already setting the Selection to be empty whenever my TextFieldValue changes
I also tried wrapping my TextField in a DisableSelection block, but it didn’t make a difference.
This icon doesn’t show up on initial focus of the field, but if I tap on it again after the field is focused then it shows and I can’t get it to disappear until a new character is entered.
a
Not sure, can you try to play with colors that we are passing to TextField. Initially pass transparent color to all color fields and check weather the selection drop is transparent or not. If works then this is a hack.
j
thanks, good suggestion. I forgot to mention that I’m already doing that. I’m setting the following colors to transparent:
Copy code
cursorColor = Color.Transparent,
                unfocusedIndicatorColor = Color.Transparent,
                focusedIndicatorColor = Color.Transparent,
                disabledIndicatorColor = Color.Transparent,
                errorIndicatorColor = Color.Transparent,
                backgroundColor = Color.Transparent,
                errorCursorColor = Color.Transparent,
All of the other colors seem to be for specific things that I wouldn’t expect to to impact this icon. I’ll take another look though to make sure
@Abhinav Suthar, I figured it out! the Colors going into the TextField composable didn’t have anything that would change it, but while digging into that I found that the text selection colors are provided via Composition Local. So I was able to wrap it in my own custom CompositionLocalProvider with the colors set to be transparent and that did the trick.
except I set the colors to be Transparent instead of red
s
Sounds like an improvement opportunity, and would appreciate a ticket. Having said that why do you prevent me as user from selecting the text i entered? Is it because of the fact that there are 6 Texfields in the screenshot and it doesnt work as you assumed it would?
j
It isn’t 6 text fields. It’s a single text field with a Visual transformation that adds the dashes for every character that hasn’t been entered yet. It’s for a Pin Entry field
👍 1
That is a fair question about not preventing the user from selecting their own text. With the visual transformation applied, we don’t want the cursor or any of the indicators to display. Without the cursor being visible, it’s really confusing if the user can move the cursor around and then insert text. So I keep the cursor at the end of the entered text at all times.
The user is entering a 6 digit pin, so I don’t think it’s too prohibitive to require them to edit the text via typing and backspacing as needed. they can still paste in the pin as well
t
@Siyamed Do we have ticket for this? If not, I can create one.
j
I didn’t log one. This seems like it's working as designed to me. The text selection colors are provided via composition local instead of through parameters on any given Composable. You could log a ticket for an enhancement to add those parameters to the textFieldColors object to override the composition local settings I guess since it seems like a common use case.