-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FIX: Caret moves to a wrong position when uploading an image via toolbar #15684
FIX: Caret moves to a wrong position when uploading an image via toolbar #15684
Conversation
6554cf1
to
51a6e42
Compare
51a6e42
to
498071e
Compare
This pull request has been mentioned on Discourse Meta. There might be relevant details there: https://meta.discourse.org/t/caret-moves-to-end-of-line-when-uploading-an-image-via-toolbar/214822/8 |
@@ -477,7 +477,7 @@ export default Component.extend(TextareaTextManipulation, { | |||
key: "#", | |||
afterComplete: (value) => { | |||
this.set("value", value); | |||
return this._focusTextArea(); | |||
return schedule("afterRender", this, this._focusTextArea); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need the return
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need it, you're right.
…oading-an-image-via-toolbar
It's not like there is a roadblock that is too hard to deal with. It just needs a bit more time to play with, when I'm testing it I see that the bug is clearly solved but something unusual is happening in the test environment. I wanted to merge it to dogfood it a bit and then backport to the release. What if I deal with the test early next week, and ping @CvX or @jjaffeux in case it takes too much time? |
Turned out that this fixes the bug only when running under Ember CLI. The PR for the legacy environment is upcoming. |
When uploading an image, we change the uploading placeholder several times. Every time, we correct the position of the cursor after replacing. But we schedule repositioning of cursor to the
afterRender
queue in Ember Run Loop. As a result, sometimes we replace the placeholder several times but correct the cursor position only once at the end.It just cannot work correctly with scheduling, we'll always be dealing with cumulative error. Removing scheduling fixes the problem.
Sadly, I cannot make the test work, I skipped it for now, going to give it another try later.