Commit 2b0f4d4a authored by Alexei Filippov's avatar Alexei Filippov Committed by Commit Bot

DevTools: Fix search in heap snapshot losing focus.

- Make UI.ToolbarInput control to not grab focus on text change.
- Make sure revealTreeNode always resolves.

BUG=825274

Change-Id: Ibb4439ecc131cc74d51546c0d2247c4579735f9f
Reviewed-on: https://chromium-review.googlesource.com/978858
Commit-Queue: Alexei Filippov <alph@chromium.org>
Reviewed-by: default avatarJoel Einbinder <einbinder@chromium.org>
Cr-Commit-Position: refs/heads/master@{#546139}
parent 87cd9251
......@@ -440,6 +440,13 @@ Profiler.HeapSnapshotViewportDataGrid = class extends Profiler.HeapSnapshotSorta
return new Promise(resolve => {
console.assert(!this._scrollToResolveCallback);
this._scrollToResolveCallback = resolve.bind(null, node);
// Still resolve the promise if it does not scroll for some reason.
this.scrollContainer.window().requestAnimationFrame(() => {
if (!this._scrollToResolveCallback)
return;
this._scrollToResolveCallback();
this._scrollToResolveCallback = null;
});
});
}
......
......@@ -342,7 +342,7 @@ Profiler.HeapSnapshotView = class extends UI.SimpleView {
this._searchableView.updateSearchMatchesCount(this._searchResults.length);
if (this._searchResults.length)
this._currentSearchResultIndex = nextQuery.jumpBackwards ? this._searchResults.length - 1 : 0;
return this._jumpToSearchResult(this._currentSearchResultIndex);
await this._jumpToSearchResult(this._currentSearchResultIndex);
}
/**
......@@ -372,6 +372,8 @@ Profiler.HeapSnapshotView = class extends UI.SimpleView {
*/
async _jumpToSearchResult(searchResultIndex) {
this._searchableView.updateCurrentMatchIndex(searchResultIndex);
if (searchResultIndex === -1)
return;
const node = await this._dataGrid.revealObjectByHeapSnapshotId(String(this._searchResults[searchResultIndex]));
this._selectRevealedNode(node);
}
......
......@@ -275,6 +275,7 @@ QuickOpen.FilteredListWidget = class extends UI.VBox {
* @param {string} query
*/
setQuery(query) {
this._prompt.focus();
this._prompt.setText(query);
this._queryChanged();
this._prompt.autoCompleteSoon(true);
......@@ -295,6 +296,7 @@ QuickOpen.FilteredListWidget = class extends UI.VBox {
}
if (!completion)
return false;
this._prompt.focus();
this._prompt.setText(completion);
this._prompt.setDOMSelection(userEnteredText.length, completion.length);
this._scheduleFilter();
......
......@@ -295,13 +295,8 @@ UI.SearchableView = class extends UI.VBox {
_updateSearchNavigationButtonState(enabled) {
this._replaceButtonElement.disabled = !enabled;
this._replaceAllButtonElement.disabled = !enabled;
if (enabled) {
this._searchNavigationPrevElement.classList.add('enabled');
this._searchNavigationNextElement.classList.add('enabled');
} else {
this._searchNavigationPrevElement.classList.remove('enabled');
this._searchNavigationNextElement.classList.remove('enabled');
}
this._searchNavigationPrevElement.classList.toggle('enabled', enabled);
this._searchNavigationNextElement.classList.toggle('enabled', enabled);
}
/**
......
......@@ -174,9 +174,14 @@ UI.TextPrompt = class extends Common.Object {
this.clearAutocomplete();
this._element.textContent = text;
this._previousText = this.text();
if (this._element.hasFocus()) {
this.moveCaretToEndOfPrompt();
this._element.scrollIntoView();
}
}
this.moveCaretToEndOfPrompt();
this._element.scrollIntoView();
focus() {
this._element.focus();
}
/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment