Skip to content

Fix bug where cursor would jump to the end of playground input - #4

Open
clarkewing wants to merge 1 commit into
opsgroupdev:mainfrom
clarkewing:bugfix/playground-jumping-cursor
Open

Fix bug where cursor would jump to the end of playground input#4
clarkewing wants to merge 1 commit into
opsgroupdev:mainfrom
clarkewing:bugfix/playground-jumping-cursor

Conversation

@clarkewing

Copy link
Copy Markdown

In the current implementation of the Playground, in order to facilitate inputing NOTAMs, the input automatically capitalizes all inputted text.

This is accomplished with the following attribute on the <textarea> element:

oninput="this.value = this.value.toUpperCase()"

This introduced a bug where the cursor jumps to the end of the input string when the input string is changed elsewhere than at its end.

This PR fixes this annoyance by capturing the cursor position prior to capitalization and restoring it afterwards:

oninput="let p = this.selectionStart; this.value = this.value.toUpperCase(); this.setSelectionRange(p, p);"

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

Successfully merging this pull request may close these issues.

1 participant