Skip to content
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

After pressing the enter key, focus jumps to the top of the page. #1407

Closed
malworthy opened this issue Jun 4, 2024 · 11 comments
Closed

After pressing the enter key, focus jumps to the top of the page. #1407

malworthy opened this issue Jun 4, 2024 · 11 comments
Labels
Milestone

Comments

@malworthy
Copy link

Details
After pressing the enter key, focus jumps to the top of the page.

To Reproduce
Can be replicated in the options sample: http://suneditor.com/sample/html/options.html
Click into the editor. Press enter key. Focus will go to the top of the screen.

Only happens in v2.46.3 of Suneditor, Issue not present in v2.45.1

Expected behaviour
For focus to stay in the control after pressing the enter key

  • OS: Windows 10
  • Browser: Chrome
  • Version: 122.0.6261.129
@andylwelch
Copy link
Contributor

I am also experiencing the issue with lost focus on enter key presses. It started occuring in v2.46.0. Looking through the change logs I suspect this change set

Specifically e.preventDefault() is changed to call event._enterPrevent(e)

image

and there is an _enterPrevent() which triggers a focus event elsewhere: this.__focusTemp.focus();

image

Thanks for your efforts!

@alexlaw-leo
Copy link

alexlaw-leo commented Jul 5, 2024

I think you're on to something there.

We've had a few people with laptops experience this, but most with laptops or desktops have no issue. Until I read this thread yesterday I couldn't reproduce it on my desktop.

This morning I learned how to set the user agent in Chrome, I chose iPad to make it appear mobile, and this trips the issue consistently. I've tested both in our application and at http://suneditor.com/sample/index.html

I'm not convinced it's the user agent necessarily, though. Perhaps something else in this:

this.isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) || 'ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0;

EDIT: OK, now I'm sure it's the touch points test. It's being flagged as a mobile device on our laptops that support touch screen input.

image

@alexlaw-leo
Copy link

OK, I've messed about with this to trip or prevent the issue:

image

I have no solution at this point other than locking the version of the library at 2.45.1.

@malworthy
Copy link
Author

The laptop I'm experiencing this issue on has a touchscreen - so touch points theory hold up.

@BestLemoon
Copy link

same problem, but solved by locking to v2.45.1

@jreynolds12
Copy link

Is there any progress here? Unfortunately, we upgraded to > 2.46.0 to fix a different bug, so feels wrong to rollback to undo that.

@JiHong88 JiHong88 added the bug label Aug 11, 2024
@JiHong88 JiHong88 added this to the 2.47.0 milestone Aug 11, 2024
@JiHong88
Copy link
Owner

This is code added due to a composition event issue with the IME input device on mobile.
I will modify it so that scrolling does not occur.

JiHong88 added a commit that referenced this issue Aug 11, 2024
@JiHong88
Copy link
Owner

@andylwelch @alexlaw-leo @malworthy @BestLemoon @jreynolds12
Version 2.47.0 has been updated.
thank you

onedark23 pushed a commit to onedark23/suneditor that referenced this issue Aug 12, 2024
onedark23 pushed a commit to damoang/suneditor that referenced this issue Aug 12, 2024
@alexlaw-leo
Copy link

@JiHong88 Thank you!

@CorinnaZer
Copy link

CorinnaZer commented Oct 2, 2024

@JiHong88 I still have this issue even with 2.47.0 version, it seems to be related to touch devices. When I press enter focus still goes on the top of the page and I can't go on writing. Pressing enter should just add a line.

@johnnybaida
Copy link

johnnybaida commented Oct 2, 2024

Hi @JiHong88, I also have the same problem.
I am using Firefox 130.0.1, in the desktop version.

I am attaching a video where I press ENTER and then see the focus disappear and via console, I see that the focus is on another element.

screen-recorder-wed-oct-02-2024-15-09-12.webm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants