-
Notifications
You must be signed in to change notification settings - Fork 54
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 cursor navigation and backspace functionality CodeTool #76
base: master
Are you sure you want to change the base?
Conversation
src/index.ts
Outdated
if (textarea.value.length > 0) { | ||
event.stopPropagation(); | ||
} else { |
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.
please, explain this case
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.
event.stopPropagation()
This keeps backspace
and cursor
keys from triggering other key event listeners in the application or editor that might interfere with navigation within the textarea.
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.
the question is more about event.preventDefault();
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.
I read somewhere that in Firefox backspace
could navigate back to previous page and it was removed in the recent versions (3 years ago 😬I guess). I will remove that as it doesn't has any impact.
case 'ArrowDown': | ||
case 'ArrowLeft': | ||
case 'ArrowRight': | ||
event.stopPropagation(); |
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.
why do need this?
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.
For navigating through textarea, we use cursor keys and the reason for using stopPropagation()
is same as above.
Problem:
Users were unable to delete text with
backspace
and navigate through code.Solution:
Adjusted the
keydown
event handling in the CodeTool textarea by allowing default behavior for the backspace key while preventing caret navigation issues, ensuring normal text deletion and proper cursor movement across all browsers.closes #67