Skip to content

replaceText duplicates the string when a maxLength is set #3530

@kaibarnes

Description

@kaibarnes

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. #921

What was the expected behaviour?

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

Was it tested on latest Detox?

  • 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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions