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.


@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?


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?


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


@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.


@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.


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


Here is the fix for the problem:


Looks like we regressed here :thinking:

However I upload (via the toolbar, drag & drop or copy & paste), the caret moves to the end of the post (not the line).

At least on latest macOS / Safari.

@cvx any chances you know what’s what? I’m OK to drop this one if it’s a hard one to fix.

1 Like