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

Mobile performance issues #115

Closed
rask opened this issue Jun 16, 2024 · 2 comments
Closed

Mobile performance issues #115

rask opened this issue Jun 16, 2024 · 2 comments

Comments

@rask
Copy link

rask commented Jun 16, 2024

I'm implementing code-input on my personal website, inside an admin panel to write Markdown posts with.

On desktop it performs well, and is great to use. But on a mobile browser, it is literally unusable.

I have a regular text field above the code-input field, which can receive near instant character input if I keep fiddling randomly on the virtual mobile keyboard, typing in tons of characters per second. The code-input field on the other hand freezes for a second or two after each character typed in, and any characters typed during this period get discarded.

I'm running Firefox mobile with an up to date Android system on a new-ish XR21 Nokia phone. I'm not a mobile development expert so I can't even begin to think what might be causing this. I do understand that JavaScript powered text areas on steroids cannot compete with a plain input field in any way, but this does not seem like normal operation to me either.

Any ideas on how to start debugging this?

@WebCoder49
Copy link
Owner

WebCoder49 commented Jun 16, 2024

Thank you for pointing this out, and sorry for the inconvenience - as this library builds on top of a textarea, it should work as well as a textarea on a mobile phone. I can reproduce your bug in Chrome on Android for code-input version 2.3, but not for 2.2.

I believe the bug is due to these lines of code, because these lines' functionality was first introduced in version 2.3, the first version of code-input in which this specific bug occurs:

code-input/code-input.js

Lines 526 to 532 in a404473

// If editing here, scroll to the caret by focusing, though this shouldn't count as a focus event
if(this.textareaElement === document.activeElement) {
this.handleEventsFromTextarea = false;
this.textareaElement.blur();
this.textareaElement.focus();
this.handleEventsFromTextarea = true;
}

Short-term Workaround

You can downgrade to version 2.2.1 of code-input. There shouldn't be too noticeable a difference unless you use a screenreader / solely keyboard navigation, and no plugins should be lost.

Long term Solution

We need another way to scroll to the textarea's caret that doesn't temporarily blur the textarea, and/or remove this scrolling (Issue #93).

@rask
Copy link
Author

rask commented Jun 19, 2024

Hey, downgrading to 2.2.1 fixed the performance issue. Many thanks! :)

I'll close this as you already seem to know what's up and have a separate issue for it. Let me know if you need more info so I can maybe try to find time to test things out.

@rask rask closed this as completed Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants