Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Now search history is stored in state and can be traversed using arrow keys while focus is on search text #13237

Merged
merged 4 commits into from
Mar 29, 2017

Conversation

saurabh95
Copy link
Contributor

This implementation doesn't have any UI as per this PR. We can have a discussion regarding its UI. There is also a trello card regarding the same with UI also https://trello.com/c/IzACddEv/344-s-find-recent-search-history .
Will have UI implementation(as per the discussion) in next PR.

searchHistory.splice(searchQueryIndex, 1);
} else {
if (searchHistory.length === maxCount) {
searchHistory.splice(maxCount - 1, 1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't .pop() the same thing?

@@ -333,6 +346,15 @@ define(function (require, exports, module) {
// if Shift is held down).
self.trigger("doFind", e.shiftKey);
}
currentIndex = 0;
} else if (e.keyCode === KeyEvent.DOM_VK_DOWN) {
currentIndex = (currentIndex - 1 + Math.min(maxCount, searchHistory.length)) % Math.min(maxCount, searchHistory.length);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (140 chars)

@@ -267,6 +267,7 @@ define(function (require, exports, module) {
FindBar._addFindBar(this);

var $root = this._modalBar.getRoot();
var currentIndex = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rename this to historyIndex or something little more specific

$("#find-what").val(searchHistory[currentIndex]);
self.trigger("queryChange");
} else if (e.keyCode === KeyEvent.DOM_VK_UP) {
currentIndex = (currentIndex + 1 + Math.min(maxCount, searchHistory.length)) % Math.min(maxCount, searchHistory.length);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you wrap if (e.keyCode === KeyEvent.DOM_VK_DOWN) and if (e.keyCode === KeyEvent.DOM_VK_UP) { codes into a function taking an argument up or down? code seems to repeat itself

Copy link
Collaborator

@swmitra swmitra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementation looks good to me. We might want to add some UI at a later point of time.

@swmitra
Copy link
Collaborator

swmitra commented Mar 29, 2017

@saurabh95 Great job! This is a very handy feature for developers. Keep these coming... 👍

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

Successfully merging this pull request may close these issues.

None yet

3 participants