Skip to content
This repository was archived by the owner on Mar 3, 2023. It is now read-only.

Fix unresponsive text input after double-clicking - #2522

Merged
probablycorey merged 3 commits into
masterfrom
cj-fix-react-double-click-bug
Jun 6, 2014
Merged

probablycorey merged 3 commits into
masterfrom
cj-fix-react-double-click-bug

Conversation

@probablycorey

Copy link
Copy Markdown

This fixes the bug, but it raises some concerns as well. I'll go though how I debugged this in case it helps shed some more light on the problem.

TL;DR it is fixed but I don't know what was causing it.

Atom handles text input using a hidden input field. I suspected that the problem was this hidden input field was losing focus, so I added setInterval((-> console.log document.activeElement), 1000) to my ~/.atom/init.coffee file. This logs if the hidden input loses focus. After double clicking around awhile the hidden input would lose focus and the body element would become focused.

I noticed the mouseDown event was being caught in an unknown parent of EditorComponent and would focus the body element. When the dev tools are used to look at what is bound to the mouseDown event you can see a react component is bound (expected) and a jquery object (unexpected):

editor-component coffee - _users_corey_github_atom

I solved this by making sure the mouseDown event in EditorComponent doesn't bubble. But I still wanted to know what event handler was causing this problem. I searched in Atom Core for mousedown handlers but none of those caused the problem. This led me to believe the problem was in a package, so I ran Atom in safe mode (atom --safe), which will start Atom with out any downloaded packages. In safe mode I could still recreate the problem. But the jquery mousedown event was no longer in the dev tools event viewer. I found out it was the color-viewer package that was adding the mousedown event handler to body, but removing that package didn't fix the problem.

So I'm left wondering what the problem was and why it only happened with the react editor.

Closes #2459

@benogle

benogle commented Jun 6, 2014

Copy link
Copy Markdown
Contributor

Maybe it's got something to do with the missing overlayer in the react editor? You're interacting directly with the text node, so maybe it's trying to focus on that text node.

Comment thread src/editor-component.coffee Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's event rather than e.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Gah!

@probablycorey

Copy link
Copy Markdown
Author

probablycorey pushed a commit that referenced this pull request Jun 6, 2014
Fix unresponsive text input after double-clicking
@probablycorey
probablycorey merged commit 776e8a3 into master Jun 6, 2014
@probablycorey
probablycorey deleted the cj-fix-react-double-click-bug branch June 6, 2014 15:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Making a selections sometimes causes the cursor to stop responding

3 participants