From 6a0ecd243d4513507b85bc9bd37deb2d61a3bad7 Mon Sep 17 00:00:00 2001 From: Abe Jellinek Date: Tue, 6 Dec 2022 13:51:50 +0100 Subject: [PATCH] v-t: Fix freeze when type-to-find wraps and first row is selected --- chrome/content/zotero/components/virtualized-table.jsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/components/virtualized-table.jsx b/chrome/content/zotero/components/virtualized-table.jsx index 84ec069789..91a2f79eca 100644 --- a/chrome/content/zotero/components/virtualized-table.jsx +++ b/chrome/content/zotero/components/virtualized-table.jsx @@ -639,7 +639,10 @@ class VirtualizedTable extends React.Component { } } else { - for (let i = (this.selection.focused) % rowCount; i != this.selection.focused - 1; i = (i + 1) % rowCount) { + // Stop at the row before the selection's focus + // but don't set a negative stop point, or we'll loop infinitely + let stopRow = Math.max(this.selection.focused - 1, 0); + for (let i = (this.selection.focused) % rowCount; i != stopRow; i = (i + 1) % rowCount) { let rowString = this.props.getRowString(i); if (rowString.toLowerCase().indexOf(this._typingString) == 0) { if (i != this.selection.focused) {