ether / ep_comments_page

Comments in Etherpad - No Longer Highly Experimental, now highly awesome!
Apache License 2.0
42 stars 48 forks source link

fixed focusing bug in new comment form #220

Closed henrik-wolf closed 2 years ago

henrik-wolf commented 2 years ago

When you add a new comment, the text field which pops up should automatically get the focus. This behaviour was expressed in the code but unfortunately not working. I believe this is due to focus() being called before the form is visible. By adding an interval that repeatedly tries to change the focus (until it works) with small times in between I was able to fix this problem.

rhansen commented 2 years ago

I think it would be better to await a new Promise that resolves when the element's transitionend event fires.

henrik-wolf commented 2 years ago

I agree that this is much cleaner. Although I do not think it is necessary to await anything. In the new commit I put everything into the transitionend event. Now, after the transition turns the box visible we focus on the text field. If you still think this should be handled in an asynchronous function, could you give me some pointers as to what would be the preferred pattern for doing something like this?

rhansen commented 2 years ago

@SuperGrobi I think I found a better way to fix the focus bug: https://github.com/ether/etherpad-lite/pull/5485

It still requires a change in ep_comments_page, so I rebased your branch and pushed some changes. If everything looks OK to you I'll squash my changes with yours and merge.

Though we should probably add a test first...

rhansen commented 2 years ago

I added a test.