-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Add option for first highlight index in Quick Open and Search History #13444
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,6 +91,13 @@ define(function (require, exports, module) { | |
|
||
$input.on("input", this._handleInput); | ||
$input.on("keydown", this._handleKeyDown); | ||
|
||
// For search History this flag is set to false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The flag is set to |
||
if (options.shouldHighLightFirstIndex === undefined) { | ||
this._shouldHighLightFirstIndex = true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we just do this._shouldHighLightFirstIndex === options.shouldHighLightFirstIndex || true There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this case if we pass false then it will taken as true, that's why I had to explicitly add the conditional statements |
||
} else { | ||
this._shouldHighLightFirstIndex = options.shouldHighLightFirstIndex; | ||
} | ||
|
||
this._dropdownTop = $input.offset().top + $input.height() + (options.verticalAdjust || 0); | ||
} | ||
|
@@ -277,7 +284,11 @@ define(function (require, exports, module) { | |
QuickSearchField.prototype._render = function (results, query) { | ||
this._displayedQuery = query; | ||
this._displayedResults = results; | ||
this._highlightIndex = null; | ||
if (this._shouldHighLightFirstIndex) { | ||
this._highlightIndex = 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now that I think of it, wouldn't it be easier to go with |
||
} else { | ||
this._highlightIndex = null; | ||
} | ||
// TODO: fixup to match prev value's item if possible? | ||
|
||
if (results.error || results.length === 0) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
shouldHighlightFirstIndex
, the L in Light looks kinda unnaturalThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we explicitly add this to the quick open field too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we should keep the highlighting for first element as default, and if someone wants to explicitly remove this he can pass false.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh sorry for the vague comment, I meant to explicitly add it as
shouldHighLightFirstIndex: true
in the Quick Open so it's defined in both.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah we can do that