In testing how can i perform typing without specif...
# compose
a
In testing how can i perform typing without specifying a node? ie on desktop i just type things, but i don't type things on a specific node
z
if you want to send the input to the window you could use
rule.onRoot()
i think
a
Im getting this error. Not sure what to make of it. I think it says root cant be focused therfore can't be 'typed'? Line:
onRoot().performTextInput("A")
Error:
Copy code
Failed to perform text input.
Failed to assert the following: (RequestFocus is defined)
Semantics of the node:
Node #1 at (l=0.0, t=0.0, r=50.0, b=50.0)px
IsTraversalGroup = 'true'
Has 1 child
Selector used: (isRoot)
z
i think you want
performKeyInput
if you're trying to simulate individual hardware keys
although that might fail for the same reason, not sure
a
using performKeyInput does not fail but it doesn't seem to be doing any typing
when doing onRoot() that is
z
where are you actually handling the input in your app?
like where do you have the modifier
a
what modifier? im using a BasicTextField
there is no text input modifier is there?
z
wait why can't you just find the text field node then?
rule.onNode(keyIsDefined(IsEditable)).whatever
a
I am building a TextField() composable which uses a BasicTextField internally. it has a 'leading' slot which places a component inside of the decoration box of the basic text field. there was a bug where if the leading had a focusable item (ie a button) and it is focused, typing stuff would input them to the text field I want to test that if the leading content is focused, then key presses don't input text
z
select the leading content node to input text on?
although depending on the bug, i'm not sure if that's even testable. Was it a compose bug?
a
select the leading content node to input text on?
I think i tried that and it would not reproduce the bug i mentioned above
im done for the day, but u made me realize that it might be a bug in CMP. i should test this on android with a keyboard to see how it works (tomorrow)
Was it a compose bug?
hard to tell. BasicTextField() is a tough one to work with so far. i can see why this behavior is work as intended from a technical POV, but defo not expected UX
z
i think it's WAI that any text input that happens while anything in the decoration box is focused, so this might be a feature request
a
will check tomorrow. i have this impression that nested focus targets are not nicely supported in compose. want to check how that behaves first
z
that's probably true