Detox icon indicating copy to clipboard operation
Detox copied to clipboard

replaceText duplicates the string when a maxLength is set

Open kaibarnes opened this issue 3 years ago • 5 comments

What happened?

In a TextInput with a maxLength prop set, calling replaceText with a string that has a length over half of the maxLength causes the string to be repeated at the start of the input.

For example

<TextInput testID='testInput' maxLength={10} >
element(by.id('testInput')).replaceText('abcdef');

causes the TextInput value to become abcdabcdef

It seems this was reported back in 2018 but wasn't addressed. https://github.com/wix/Detox/issues/921

What was the expected behaviour?

That replaceText would only enter the specified string once in the TextInput

Was it tested on latest Detox?

  • [X] I have tested this issue on the latest Detox release and it still reproduces.

Did your test throw out a timeout?

Help us reproduce this issue!

  1. Create a TextInput component with a maxLength, e.g. maxLength={10}
  2. In a test, call replaceText on the above TextInput using a string with a length >= half of the maxLength, e.g. 'abcdef'
  3. Run the test and see the TextInput value become abcdabcdef

In what environment did this happen?

Detox version: 19.9.0 React Native version: 0.66.4 Node version: 16.14.0 Device model: iPhone 13 iOS version: 15.2 Test-runner (select one): jest-circus

Detox logs

Detox logs
15:16:18.746 detox[98658] TRACE: [WS_SEND] {"type":"invoke","params":{"type":"action","action":"replaceText","params":["abcdef"],"predicate":{"type":"id","value":"TEST"}},"messageId":18}
15:16:18.746 detox[98658] TRACE: [WSS_GET_FROM, #tester] {"type":"invoke","params":{"type":"action","action":"replaceText","params":["abcdef"],"predicate":{"type":"id","value":"TEST"}},"messageId":18}
15:16:18.746 detox[98658] TRACE: [WSS_SEND_TO, #app] {"type":"invoke","params":{"type":"action","action":"replaceText","params":["abcdef"],"predicate":{"type":"id","value":"TEST"}},"messageId":18}
15:16:20.346 detox[98658] TRACE: [WSS_GET_FROM, #app] {"params":{},"messageId":18,"type":"invokeResult"}
15:16:20.346 detox[98658] TRACE: [WSS_SEND_TO, #tester] {"params":{},"messageId":18,"type":"invokeResult"}
15:16:20.347 detox[98658] TRACE: [WS_MESSAGE] {"params":{},"messageId":18,"type":"invokeResult"}

Device logs

Device logs
paste logs here!

More data, please!

No response

kaibarnes avatar Aug 04 '22 07:08 kaibarnes

Thanks for reporting @kaibarnes! I will try to reproduce this issue using the steps you provided.

asafkorem avatar Aug 07 '22 07:08 asafkorem

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe the issue is still relevant, please test on the latest Detox and report back.

Thank you for your contributions!

For more information on bots in this reporsitory, read this discussion.

stale[bot] avatar Sep 08 '22 16:09 stale[bot]

It seems this issue is still reproducible on 20.17.0. Except using typeText instead, any other way to fix it?

lclnrd avatar Mar 07 '24 12:03 lclnrd

@lclnrd Hopefully, Asaf will be back soon (we miss him too) and will be able to look. Otherwise, pull requests are welcome.

noomorph avatar Mar 09 '24 07:03 noomorph