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

Uncaught TypeError: Cannot read property 'focus' of null #1

Closed
yasaricli opened this issue Sep 9, 2015 · 8 comments
Closed

Uncaught TypeError: Cannot read property 'focus' of null #1

yasaricli opened this issue Sep 9, 2015 · 8 comments
Labels

Comments

@yasaricli
Copy link

[Enter steps to reproduce below:]

  1. ...
  2. ...

Atom Version: 1.0.11
System: Mac OS X 10.10.5
Thrown From: terminal-plus package, v0.1.2

Stack Trace

Uncaught TypeError: Cannot read property 'focus' of null

At /Users/yasaricli/.atom/packages/terminal-plus/lib/view.coffee:202

TypeError: Cannot read property 'focus' of null
  at /Users/yasaricli/.atom/packages/terminal-plus/lib/view.coffee:202:26
  at HTMLDivElement.<anonymous> (/Users/yasaricli/.atom/packages/terminal-plus/lib/view.coffee:324:7)
  at HTMLDivElement.fn (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/jquery/dist/jquery.js:4855:19)
  at HTMLDivElement.jQuery.event.dispatch (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/jquery/dist/jquery.js:4435:9)
  at HTMLDivElement.elemData.handle (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/jquery/dist/jquery.js:4121:28)

Commands

     -4:53 application:add-project-folder (atom-text-editor.editor.is-focused)

Config

{
  "core": {}
}

Installed Packages

# User
color-picker, v2.0.11
docs-snippets, v0.8.0
linter-jshint, v1.1.4
minimap, v4.13.3
pigments, v0.14.0
terminal-plus, v0.1.2

# Dev
No dev packages
@jeremyramin
Copy link
Owner

@yasaricli I'll take a look, thanks for letting me know.

jeremyramin added a commit that referenced this issue Sep 9, 2015
Check for a null lastActiveElement before attempting to focus it. This
fixes #1.
@jeremyramin jeremyramin added the bug label Sep 9, 2015
@yasaricli
Copy link
Author

👍

@sabrehagen
Copy link

[Enter steps to reproduce below:]

  1. ...
  2. ...

Atom Version: 1.5.0-beta0
System: Ubuntu 14.04.3
Thrown From: terminal-plus package, v0.14.5

Stack Trace

Uncaught TypeError: Cannot read property 'focus' of null

At /home/jackson/.atom/packages/terminal-plus/lib/status-bar.coffee:92

TypeError: Cannot read property 'focus' of null
    at /home/jackson/.atom/packages/terminal-plus/lib/status-bar.coffee:92:23

Commands

     -6:53.7.0 editor:select-to-end-of-line (atom-text-editor.editor.is-focused)
  2x -6:53.5.0 core:select-left (atom-text-editor.editor.is-focused)
     -6:52.6.0 core:backspace (atom-text-editor.editor.is-focused)
     -6:51.4.0 core:save (atom-text-editor.editor.is-focused)
  6x -6:50.5.0 core:move-down (atom-text-editor.editor.is-focused)
     -6:49.5.0 editor:select-to-first-character-of-line (atom-text-editor.editor.is-focused)
     -6:48.9.0 core:backspace (atom-text-editor.editor.is-focused)
     -6:48.7.0 core:save (atom-text-editor.editor.is-focused)
  4x -6:35 pane:show-next-item (atom-text-editor.editor.is-focused)
     -6:34.1.0 pane:show-previous-item (atom-text-editor.editor.is-focused)
     -3:05.9.0 core:copy (atom-text-editor.editor.is-focused)
  2x -3:03.0 core:backspace (atom-text-editor.editor.is-focused)
  2x -3:02.2.0 core:move-right (atom-text-editor.editor.is-focused)
     -3:01.2.0 core:backspace (atom-text-editor.editor.is-focused)
     -2:59.9.0 core:save (atom-text-editor.editor.is-focused)
     -2:59.3.0 core:move-to-top (atom-text-editor.editor.is-focused)

Config

{
  "core": {
    "autoHideMenuBar": true,
    "ignoredNames": [
      "\"node_modules\"",
      "\"bower_components\"",
      "\".git\"",
      "\".tmp\"",
      "\".sass-cache\"",
      "\"app/assets\"",
      "\"architecture\"",
      "\"docs\"",
      "\"build\"",
      "\"dist\"",
      "\"vendor\"",
      "\"server/logs\"",
      "\"admin/assets\"",
      "\"*.css\"",
      "\"*.map\"",
      "\"*.scss\"",
      "\"*.bak\"",
      "\".elasticbeanstalk\"",
      "\".cache-require-paths.json\"",
      "\"server/uploads\""
    ],
    "packagesWithKeymapsDisabled": [
      "symbols-view",
      "refactor"
    ],
    "projectHome": "/home/jackson/repositories",
    "themes": [
      "one-dark-ui",
      "base16-tomorrow-dark-theme"
    ]
  }
}

Installed Packages

# User
highlight-selected, v0.11.1
linter, v1.11.3
linter-jshint, v1.2.2
minimap, v4.19.0
minimap-autohide, v0.10.1
minimap-find-and-replace, v4.4.0
minimap-selection, v4.3.1
refactor, v0.6.0
rest-client, v0.5.0
terminal-plus, v0.14.5

# Dev
No dev packages

@fusion809
Copy link

fusion809 commented Mar 31, 2016

I'm getting the same error:

[Enter steps to reproduce below:]

  1. ...
  2. ...

Atom Version: 1.7.0-beta4
System: linux 4.4.5-1-ARCH (Arch Linux)
Thrown From: terminal-plus package, v0.14.5

Stack Trace

Uncaught TypeError: Cannot read property 'focus' of null

At /home/fusion809/.atom/packages/terminal-plus/lib/status-bar.coffee:92

TypeError: Cannot read property 'focus' of null
    at /home/fusion809/.atom/packages/terminal-plus/lib/status-bar.coffee:92:23

Commands

Config

{
  "core": {
    "allowPendingPaneItems": false,
    "disabledPackages": [
      "language-markdown"
    ],
    "ignoredNames": [
      ".git",
      ".osc",
      ".svn",
      ".hg"
    ],
    "themes": [
      "atom-dark-ui",
      "one-dark-syntax"
    ]
  },
  "terminal-plus": {
    "core": {},
    "style": {},
    "toggles": {
      "autoClose": true
    }
  }
}

Installed Packages

# User
atomic-chrome, v0.3.0
build, v0.58.0
file-icons, v1.6.20
language-gentoo, v0.9.0
language-liquid, v0.4.0
language-lua, v0.9.4
language-matlab-octave, v0.1.1
language-rpm-spec, v0.9.0
language-sage, v0.3.0
language-scilab, v0.1.0
package-sync, v1.0.0
pigments, v0.26.0
project-manager, v2.9.0
terminal-plus, v0.14.5

# Dev
No dev packages

@ragmha
Copy link

ragmha commented Apr 17, 2016

Getting the same error:

Atom Version: 1.4.3
System: Linux Mint
Thrown From: terminal-plus package, v0.14.5

Stack Trace

Uncaught TypeError: Cannot read property 'focus' of null

At /home/rgb/.atom/packages/terminal-plus/lib/status-bar.coffee:92

TypeError: Cannot read property 'focus' of null
    at /home/rgb/.atom/packages/terminal-plus/lib/status-bar.coffee:92:23

Commands

  2x -4:22.6.0 editor:newline (atom-text-editor.editor.is-focused)
  3x -4:10.6.0 core:backspace (atom-text-editor.editor.is-focused)
  2x -4:08.9.0 core:move-right (atom-text-editor.editor.is-focused.autocomplete-active)
     -3:59.7.0 core:move-down (atom-text-editor.editor.is-focused)
  3x -3:59.2.0 core:backspace (atom-text-editor.editor.is-focused)
     -3:57.5.0 core:save (atom-text-editor.editor.is-focused)
  2x -0:52.2.0 tree-view:add-file (span.name.icon.icon-file-directory)
     -0:46.2.0 core:backspace (atom-text-editor.editor.mini.is-focused)
     -0:44.5.0 core:confirm (atom-text-editor.editor.mini.is-focused)
     -0:37.6.0 core:move-right (atom-text-editor.editor.is-focused)
     -0:37.1.0 core:save (atom-text-editor.editor.is-focused)
  2x -0:24.6.0 editor:newline (atom-text-editor.editor.is-focused)
     -0:18.5.0 core:move-right (atom-text-editor.editor.is-focused.autocomplete-active)
     -0:17.8.0 core:save (atom-text-editor.editor.is-focused)
     -0:04.6.0 tree-view:remove (span.name.icon.icon-file-text)

Config

{
  "core": {
    "disabledPackages": [
      "linter-js-standard"
    ],
    "themes": [
      "atom-material-ui",
      "oceanic-next-dark"
    ]
  },
  "terminal-plus": {
    "core": {},
    "style": {
      "theme": "dracula"
    }
  }
}

Installed Packages

# User
angularjs, v0.3.4
atom-material-ui, v1.2.10
atom-typescript, v8.8.1
browser-plus, v0.0.60
browser-refresh, v0.9.0
color-picker, v2.1.1
file-icons, v1.7.3
jsformat, v0.9.3
jshint, v1.8.5
language-babel, v2.17.3
language-javascript-jsx, v0.3.7
linter, v1.11.4
linter-flow, v5.1.0
minimap, v4.22.1
minimap-find-and-replace, v4.5.1
oceanic-next-dark, v0.0.8
open-in-browsers, v0.0.13
pigments, v0.26.0
react, v0.15.0
react-es6-snippets, v0.3.0
react-snippets, v0.4.2
source-preview-babel, v0.1.1
terminal-plus, v0.14.5
webbox-color, v0.5.9

# Dev
No dev packages

@ghost
Copy link

ghost commented May 3, 2016

Getting some error ! :us' of null

At /home/jonayad/.atom/packages/terminal-plus/lib/status-bar.coffee:92

TypeError: Cannot read property 'focus' of null
    at /home/jonayad/.atom/packages/terminal-plus/lib/status-bar.coffee:92:23

     -3:24 application:add-project-folder (textarea.)
  3x -1:16.7.0 core:save (atom-text-editor.editor.is-focused)

Config

{}

Installed Packages

# User
minimap, v4.23.2
pigments, v0.26.0
terminal-plus, v0.14.5

# Dev
No dev packages

@treaki
Copy link

treaki commented May 10, 2016

same here on debian:

[Enter steps to reproduce below:]

it just happened out of nowhere (switched desktops)

Atom Version: 1.7.3
System: Debian GNU/Linux
Thrown From: terminal-plus package, v0.14.5

Stack Trace

Uncaught TypeError: Cannot read property 'focus' of null

At /home/treaki/.atom/packages/terminal-plus/lib/status-bar.coffee:92

TypeError: Cannot read property 'focus' of null
    at /home/treaki/.atom/packages/terminal-plus/lib/status-bar.coffee:92:23

Commands

Config

{}

Installed Packages

# User
git-plus, v5.13.4
minimap, v4.23.5
pdf-view, v0.50.0
pigments, v0.26.2
terminal-plus, v0.14.5

# Dev
No dev packages

@JohnAtFenestra
Copy link

JohnAtFenestra commented May 20, 2016

Ran into the same problem. I looked over the code and it may be a race condition. The use case scenario would be one where handleFocus is called a second time before @returnFocus is set to null. The final scenario, which is highly unlikely, involves both threads passing the first guard and then thread one switching and setting @returnFocus to null before the second thread assigns to a temp variable. I added a final guard for that possibility as well.

Suggested change:

status-bar.coffee

Original

    handleFocus = =>
      if @returnFocus
        setTimeout =>
            @returnFocus.focus()
            @returnFocus = null
        , 100

Changed

    handleFocus = =>
      if @returnFocus
        setTimeout =>
          if @returnFocus
              tempFocus = @returnFocus
              @returnFocus = null
              tempFocus.focus() if tempFocus
        , 100

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants