From c2ffe0102aab095acbd247cc3b261c149499e2e0 Mon Sep 17 00:00:00 2001 From: jh-code Date: Sun, 9 Dec 2018 21:11:40 -0600 Subject: [PATCH 1/3] fix(desktop): search highlight on pagination Referencing issue standardnotes/bounties#20 --- app/assets/javascripts/app/controllers/notes.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/assets/javascripts/app/controllers/notes.js b/app/assets/javascripts/app/controllers/notes.js index 1c33e0d1b..14c29bb99 100644 --- a/app/assets/javascripts/app/controllers/notes.js +++ b/app/assets/javascripts/app/controllers/notes.js @@ -34,6 +34,7 @@ angular.module('app') .controller('NotesCtrl', function (authManager, $timeout, $rootScope, modelManager, storageManager, desktopManager) { this.panelController = {}; + this.searchEntered = false; $rootScope.$on("user-preferences-changed", () => { this.loadPreferences(); @@ -106,6 +107,10 @@ angular.module('app') this.DefaultNotesToDisplayValue = (document.documentElement.clientHeight / MinNoteHeight) || 20; this.paginate = function() { + if (this.searchEntered) { + desktopManager.searchText(this.noteFilter.text); + } + this.notesToDisplay += this.DefaultNotesToDisplayValue } @@ -262,6 +267,7 @@ angular.module('app') this.onFilterEnter = function() { // For Desktop, performing a search right away causes input to lose focus. // We wait until user explicity hits enter before highlighting desktop search results. + this.searchEntered = true; desktopManager.searchText(this.noteFilter.text); } @@ -275,6 +281,10 @@ angular.module('app') } this.filterTextChanged = function() { + if (this.searchEntered) { + this.searchEntered = false; + } + $timeout(function(){ if(!this.selectedNote.visible) { this.selectFirstNote(false); From e218c0d5a9011a5981e895a9ccc238646662cb1e Mon Sep 17 00:00:00 2001 From: jh-code Date: Mon, 10 Dec 2018 10:49:21 -0600 Subject: [PATCH 2/3] refactor(desktop): rename searchEntered to searchSubmitted Referencing issue standardnotes/web#263 --- app/assets/javascripts/app/controllers/notes.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/app/controllers/notes.js b/app/assets/javascripts/app/controllers/notes.js index 14c29bb99..05c92d611 100644 --- a/app/assets/javascripts/app/controllers/notes.js +++ b/app/assets/javascripts/app/controllers/notes.js @@ -34,7 +34,7 @@ angular.module('app') .controller('NotesCtrl', function (authManager, $timeout, $rootScope, modelManager, storageManager, desktopManager) { this.panelController = {}; - this.searchEntered = false; + this.searchSubmitted = false; $rootScope.$on("user-preferences-changed", () => { this.loadPreferences(); @@ -107,7 +107,7 @@ angular.module('app') this.DefaultNotesToDisplayValue = (document.documentElement.clientHeight / MinNoteHeight) || 20; this.paginate = function() { - if (this.searchEntered) { + if (this.searchSubmitted) { desktopManager.searchText(this.noteFilter.text); } @@ -267,7 +267,7 @@ angular.module('app') this.onFilterEnter = function() { // For Desktop, performing a search right away causes input to lose focus. // We wait until user explicity hits enter before highlighting desktop search results. - this.searchEntered = true; + this.searchSubmitted = true; desktopManager.searchText(this.noteFilter.text); } @@ -281,8 +281,8 @@ angular.module('app') } this.filterTextChanged = function() { - if (this.searchEntered) { - this.searchEntered = false; + if (this.searchSubmitted) { + this.searchSubmitted = false; } $timeout(function(){ From d7cee977dd7b6b57d802a17d37051b315b88bc8e Mon Sep 17 00:00:00 2001 From: jh-code Date: Mon, 10 Dec 2018 11:07:08 -0600 Subject: [PATCH 3/3] fix(desktop): move search text highlight logic after update of notes to display Referencing issue standardnotes/web#263 --- app/assets/javascripts/app/controllers/notes.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/app/controllers/notes.js b/app/assets/javascripts/app/controllers/notes.js index 05c92d611..8fc2ca944 100644 --- a/app/assets/javascripts/app/controllers/notes.js +++ b/app/assets/javascripts/app/controllers/notes.js @@ -107,11 +107,11 @@ angular.module('app') this.DefaultNotesToDisplayValue = (document.documentElement.clientHeight / MinNoteHeight) || 20; this.paginate = function() { + this.notesToDisplay += this.DefaultNotesToDisplayValue + if (this.searchSubmitted) { desktopManager.searchText(this.noteFilter.text); } - - this.notesToDisplay += this.DefaultNotesToDisplayValue } this.resetPagination = function() {