1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-02 12:47:41 +02:00

Desktop: Fixes #3170: Always make the first item selected in Goto Anything (#3181)

This commit is contained in:
叡山电车 2020-06-04 01:01:17 +08:00 committed by GitHub
parent 26ce102113
commit dd34b155b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -262,19 +262,14 @@ class Dialog extends React.PureComponent {
}
}
let selectedItemId = null;
const itemIndex = this.selectedItemIndex(results, this.state.selectedItemId);
if (itemIndex > 0) {
selectedItemId = this.state.selectedItemId;
} else if (results.length > 0) {
selectedItemId = results[0].id;
}
// make list scroll to top in every search
this.itemListRef.current.makeItemIndexVisible(0);
this.setState({
listType: listType,
results: results,
keywords: this.keywords(searchQuery),
selectedItemId: selectedItemId,
selectedItemId: results.length === 0 ? null : results[0].id,
resultsInBody: resultsInBody,
});
}