dbkaplun / atom-tabs-in-sidebar

Turns Atom's tab bar into a vertical list above the tree view
https://atom.io/packages/atom-tabs-in-sidebar
MIT License
7 stars 1 forks source link

Uncaught TypeError: Cannot read property 'contains' of undefined #2

Open nlaplante opened 7 years ago

nlaplante commented 7 years ago

[Enter steps to reproduce:]

  1. Install package
  2. Toggle package

Atom: 1.14.0-beta3 x64 Electron: 1.3.13 OS: Microsoft Windows 10 Pro Thrown From: atom-tabs-in-sidebar package 1.1.0

Stack Trace

Uncaught TypeError: Cannot read property 'contains' of undefined

At C:\Users\Nicolas\.atom\packages\atom-tabs-in-sidebar\lib\atom-tabs-in-sidebar.js:48

TypeError: Cannot read property 'contains' of undefined
    at Object.isTabBarActive (/packages/atom-tabs-in-sidebar/lib/atom-tabs-in-sidebar.js:48:28)
    at /packages/atom-tabs-in-sidebar/lib/atom-tabs-in-sidebar.js:41:19
    at Array.forEach (native)
    at Object.toggle (/packages/atom-tabs-in-sidebar/lib/atom-tabs-in-sidebar.js:40:18)
    at /packages/atom-tabs-in-sidebar/lib/atom-tabs-in-sidebar.js:15:51)
    at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/app.asar/src/command-registry.js:259:29)
    at CommandRegistry.handleCommandEvent (/app.asar/src/command-registry.js:3:59)
    at CommandRegistry.module.exports.CommandRegistry.dispatch (/app.asar/src/command-registry.js:160:19)
    at AtomEnvironment.module.exports.AtomEnvironment.dispatchApplicationMenuCommand (/app.asar/src/atom-environment.js:1158:28)
    at EventEmitter.outerCallback (/app.asar/src/application-delegate.js:320:25)
    at emitThree (events.js:116:13)
    at EventEmitter.emit (events.js:194:7)

Commands

     -1:08.3.0 core:paste (input.hidden-input)
  2x -1:07.8.0 core:confirm (input.hidden-input)
     -0:15.1.0 atom-tabs-in-sidebar:toggle (atom-workspace.workspace.scrollbars-visible-always.theme-atom-material-syntax.theme-one-dark-ui)

Non-Core Packages

atom-beautify 0.29.17 
atom-material-syntax 1.0.2 
atom-material-ui 1.3.9 
atom-tabs-in-sidebar 1.1.0 
atom-ternjs 0.17.0 
atom-typescript 10.1.13 
brogrammer-syntax 1.0.0 
brogrammer-ui 1.0.0 
docblockr 0.9.1 
dockerletion 0.2.0 
file-icons 2.0.12 
language-docker 1.1.7 
language-pug 0.0.19 
linter 1.11.21 
linter-docker 0.1.4 
linter-jshint 3.0.2 
linter-tslint 0.13.1 
minimap 4.26.7 
minimap-bookmarks 0.4.2 
minimap-cursorline 0.2.0 
minimap-find-and-replace 4.5.1 
minimap-git-diff 4.3.1 
minimap-highlight-selected 4.5.0 
minimap-linter 1.6.0 
minimap-pigments 0.2.2 
minimap-selection 4.4.0 
nord-atom-syntax 0.6.0 
nord-atom-ui 0.10.1 
programmer-syntax 2.0.0 
ramda-syntax 0.12.0 
sort-lines 0.14.0 
sub-monokai 1.2.3 
synced-sidebar 0.4.3 
tree-view-git-status 1.3.0 
oskude commented 6 years ago

this seems to work

diff --git a/lib/atom-tabs-in-sidebar.js b/lib/atom-tabs-in-sidebar.js
index 4b89011..cb9698d 100644
--- a/lib/atom-tabs-in-sidebar.js
+++ b/lib/atom-tabs-in-sidebar.js
@@ -45,14 +45,14 @@ export default {
   },

   isTabBarActive(tabBar) {
-    return tabBar.classList.contains(this.activeClass);
+    return tabBar.element.classList.contains(this.activeClass);
   },

   moveTabBarToSidebar(tabBar) {
     if (!this.treeView) return;
     if (this.isTabBarActive(tabBar)) return;
-    tabBar.classList.add(this.activeClass);
-    this.treeView.scroller.prepend(tabBar);
+    tabBar.element.classList.add(this.activeClass);
+    this.treeView.element.prepend(tabBar.element);
   },

   moveTabBarBack(tabBar) {
oskude commented 6 years ago

forgot to test toggle. this should fix that too.

diff --git a/lib/atom-tabs-in-sidebar.js b/lib/atom-tabs-in-sidebar.js
index 4b89011..df0a1ab 100644
--- a/lib/atom-tabs-in-sidebar.js
+++ b/lib/atom-tabs-in-sidebar.js
@@ -21,7 +21,7 @@ export default {
       this.treeView = TreeView.treeView;
       this.tabBars = Tabs.tabBarViews;
       this.tabBars.forEach(tabBar => {
-        tabBar._atomTabsInSidebar_originalParent = tabBar.parentNode;
+        tabBar._atomTabsInSidebar_originalParent = tabBar.element.parentNode;
         this.moveTabBarToSidebar(tabBar);
       });
     });
@@ -45,21 +45,21 @@ export default {
   },

   isTabBarActive(tabBar) {
-    return tabBar.classList.contains(this.activeClass);
+    return tabBar.element.classList.contains(this.activeClass);
   },

   moveTabBarToSidebar(tabBar) {
     if (!this.treeView) return;
     if (this.isTabBarActive(tabBar)) return;
-    tabBar.classList.add(this.activeClass);
-    this.treeView.scroller.prepend(tabBar);
+    tabBar.element.classList.add(this.activeClass);
+    this.treeView.element.prepend(tabBar.element);
   },

   moveTabBarBack(tabBar) {
     let originalParent = tabBar._atomTabsInSidebar_originalParent;
     if (!originalParent) return;
     if (!this.isTabBarActive(tabBar)) return;
-    tabBar.classList.remove(this.activeClass);
-    originalParent.insertBefore(tabBar, originalParent.firstChild);
+    tabBar.element.classList.remove(this.activeClass);
+    originalParent.insertBefore(tabBar.element, originalParent.firstChild);
   }
 };
vlad0337187 commented 2 years ago

Already created PR, but seems your is better one, I did this.treeView.element.childNodes[0].prepend(tabBar.element); instead of this.treeView.element.prepend(tabBar.element); which caused shift of tab titles.

Now I understood why I was wrong 😁. So I put tabBar.element inside tree view

    before first
  1. .

    Fixed according to your patch. https://github.com/dbkaplun/atom-tabs-in-sidebar/pull/3/files