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

Fix cursor navigation and backspace functionality CodeTool #76

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

idebenone
Copy link
Member

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

src/index.ts Outdated
Comment on lines 321 to 323
if (textarea.value.length > 0) {
event.stopPropagation();
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please, explain this case

Copy link
Member Author

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.

Copy link
Contributor

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();

Copy link
Member Author

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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do need this?

Copy link
Member Author

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.

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.

Cannot delete text with backspace or navigate with arrow keys in Firefox
2 participants