Caret moves to end-of-line when uploading an image via toolbar

I was noticing focus moves when you upload though, e.g. when I have focus caret in a particular location, then I upload, it moves to a weird location? That’s the main thing I want to check.

3 Likes

@martin can have a quick look, that said a repro here would be awesome, how are you uploading (cut-and-paste, drag-drop, toolbar)? browser (I assume chrome)? what is body + caret before … after?

4 Likes

So if I understand correctly, when we upload we should keep the caret in the original location after the upload is complete? I can replicate the issue:

  1. Click in the middle of the sentence
  2. Upload a file
  3. My caret is now at the end of the sentence

Peek 2022-01-14 14-32

In my gif, the caret goes to the end of the sentence as soon as the processing starts. Note that the upload and processing markdown does go in the correct place at least.

With drag + drop the character stays where it is supposed to be, same with pasting, so it seems like clicking the upload button is the only place this is an issue?

6 Likes

Yes exactly, well demonstrated! Just preserve caret location. Thanks!

4 Likes

@zogstrip can @andrei take this? It is likely related to the other feature that injects newlines.

Also need to be careful here to determine if the bug pops up when we first inject the placeholder or after we replace the placeholder with the upload. My gut is that it pops up once the placeholder is added.

Moving to a dedicated bug.

5 Likes

@andrei can you add this to your list?

Might be a tricky one as there are lots of different ways we allow users to add uploads.

2 Likes

Sure, I’ll take care of this. As Sam said this is probably related to the problem with newlines.

4 Likes

Here is the fix for the problem:

6 Likes