Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(386)

Unified Diff: third_party/WebKit/Source/devtools/front_end/ui/SuggestBox.js

Issue 2616743004: DevTools: Take subtitle into account when finding largest suggestion (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/devtools/front_end/ui/SuggestBox.js
diff --git a/third_party/WebKit/Source/devtools/front_end/ui/SuggestBox.js b/third_party/WebKit/Source/devtools/front_end/ui/SuggestBox.js
index 38c08d604cb963fb432baf0da41c984c592c60ba..cfa9f10c2ea26e3944a1c7d8729e8eb2f2b93c83 100644
--- a/third_party/WebKit/Source/devtools/front_end/ui/SuggestBox.js
+++ b/third_party/WebKit/Source/devtools/front_end/ui/SuggestBox.js
@@ -134,12 +134,20 @@ UI.SuggestBox = class {
if (!items.length)
return;
// If there are no scrollbars, set the width to the width of the largest row.
- var maxItem = items[0];
- for (var i = 1; i < items.length; i++) {
- if (items[i].title.length > maxItem.title.length)
+ var maxItem;
+ var maxLength = -Infinity;
+ for (var i = 0; i < items.length; i++) {
+ var length = items[i].title.length + (items[i].subtitle || '').length;
+ if (length > maxLength) {
+ maxLength = length;
maxItem = items[i];
+ }
}
- this._element.style.width = UI.measurePreferredSize(this.createElementForItem(maxItem), this._element).width + 'px';
+ this._element.style.width =
+ UI.measurePreferredSize(
+ this.createElementForItem(/** @type {!UI.SuggestBox.Suggestion} */ (maxItem)), this._element)
+ .width +
+ 'px';
}
/**
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698