Why is the testFieldDidChangeSelection function called three times when the return key is pressed?

Why is the testFieldDidChangeSelection function called three times when the return key is pressed?

Here is what I did

  1. enter text in TextField
  2. press the Return key

The result is that the textFieldDidChangeSelection function is called three times.

I would like to know why.

As a supplement, I asked ChatGPT and the results are below.

  1. At the moment the Return key is pressed: The cursor is updated at the position of the last character entered in the text field.
  2. Insertion of a newline: When the Return key is pressed, a new line is added, and the cursor moves to the beginning of the new line.
  3. Finalization of the edit: Finally, the content of the text field is confirmed, and the position of the cursor is finalized.

Also, is the above answer true?

@yuum Could you provide a test project that reproduces and demonstrates the issue? If so, please share a link to your test project. This will help us better understand what's going on. If you're not familiar with preparing a test project, please refer to Creating a Test Project

Why is the testFieldDidChangeSelection function called three times when the return key is pressed?
 
 
Q