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

Automatically focus on text input when the window gets focus #152

Merged
merged 1 commit into from May 23, 2017

Conversation

Projects
None yet
2 participants
@knu
Contributor

knu commented May 11, 2017

Without this, you always have to click on the text input after switching back from another application where you've copied something you intend to paste to your tweet.

@eramdam

This comment has been minimized.

Owner

eramdam commented May 11, 2017

  1. I won't merge the PR until you fix the lint issues (see the Travis build ). Most of them are indentation-related so you should be able to fix them by running the following command
    ./node_modules/.bin/eslint --fix src
  2. I guess this will fix #89 ?
@knu

This comment has been minimized.

Contributor

knu commented May 11, 2017

Oops, sorry, I just pasted my local userscript and completely missed the style issues.
Just updated the commit.

Automatically focus on text input when the window gets focus
Without this, you always have to click on the text input after
switching back from another application where you've copied something
you intend to paste to your tweet.

This should fix #89.
@knu

This comment has been minimized.

Contributor

knu commented May 11, 2017

I've fixed a typo and locally tested the extension again.

@eramdam eramdam merged commit b61d2a4 into eramdam:master May 23, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@knu knu deleted the knu:focus_on_text_input branch May 23, 2017

@eramdam

This comment has been minimized.

Owner

eramdam commented May 23, 2017

@knu FYI: I had to tweak your code a bit. You can see the commit here fc3f265.

Here is what I did:

  1. I improved the way you detect the visibility of an element, it was only using height and width. It could have worked except the <textarea> element of the tweet composer always have non-zero height/widths, it's just partially masked. I simply used getBoundingClientRect() to see if one of the top/bottom/right/left values was negative or not
  2. You listener was triggering on every focus events happening on the page, messing up with other features of TweetDeck. I added a simple check to see if the target of the event is the window or not.
@knu

This comment has been minimized.

Contributor

knu commented May 23, 2017

@eramdam Great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment