From 32253882eb793e7daa3c892aa39af14c24d26780 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 4 Mar 2019 15:01:41 +0100 Subject: [PATCH] fix fileexplorer selected file --- src/app/files/file-explorer.js | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/app/files/file-explorer.js b/src/app/files/file-explorer.js index 3222cd65cd..712e1db7c6 100644 --- a/src/app/files/file-explorer.js +++ b/src/app/files/file-explorer.js @@ -79,8 +79,8 @@ function fileExplorer (localRegistry, files) { self.focusElement = self.treeView.labelAt(self.focusPath) // TODO: here we update the selected file (it applicable) // cause we are refreshing the interface of the whole directory when there's a new file. - if (self.focusElement && !self.focusElement.classList.contains('bg-primary')) { - self.focusElement.classList.add('bg-primary') + if (self.focusElement && !self.focusElement.classList.contains('bg-secondary')) { + self.focusElement.classList.add('bg-secondary') } }) } @@ -165,17 +165,7 @@ function fileExplorer (localRegistry, files) { }) self.treeView.event.register('leafClick', function (key, data, label) { - if (self.focusElement) { - self.focusElement.classList.remove('bg-secondary') - self.focusElement = null - self.focusPath = null - } - self.focusElement = self.treeView.labelAt(key) - if (self.focusElement) { - self.focusElement.classList.add('bg-secondary') - self.focusPath = key - self.events.trigger('focus', [key]) - } + self.events.trigger('focus', [key]) }) self.treeView.event.register('nodeClick', function (path, childrenContainer) { @@ -202,11 +192,18 @@ function fileExplorer (localRegistry, files) { // register to main app, trigger when the current file in the editor changed self._deps.fileManager.events.on('currentFileChanged', (newFile) => { const explorer = self._deps.fileManager.fileProviderOf(newFile) - if (self.focusElement && (!explorer || explorer.type !== files.type) && self.focusPath !== newFile) { - self.focusElement.classList.remove('bg-primary') + if (self.focusElement && self.focusPath !== newFile) { + self.focusElement.classList.remove('bg-secondary') self.focusElement = null self.focusPath = null } + if (explorer && (explorer.type === files.type)) { + self.focusElement = self.treeView.labelAt(newFile) + if (self.focusElement) { + self.focusElement.classList.add('bg-secondary') + self.focusPath = newFile + } + } }) var textUnderEdit = null