Skip to content

Build your personal knowledge base with Trilium Notes

fix refocusing find widget, closes #3252

zadam521d95021b4c
diff --git a/package-lock.json b/package-lock.json
index b197bd93c8..2f3024b085 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "trilium",
- "version": "0.56.1",
+ "version": "0.56.2",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "trilium",
- "version": "0.56.1",
+ "version": "0.56.2",
"hasInstallScript": true,
"license": "AGPL-3.0-only",
"dependencies": {
diff --git a/src/public/app/widgets/find.js b/src/public/app/widgets/find.js
index f165c3e5f1..70116d0cb6 100644
--- a/src/public/app/widgets/find.js
+++ b/src/public/app/widgets/find.js
@@ -142,26 +142,27 @@ export default class FindWidget extends NoteContextAwareWidget {
return;
}
- if (!['text', 'code', 'render'].includes(this.note.type) || !this.$findBox.is(":hidden")) {
+ if (!['text', 'code', 'render'].includes(this.note.type)) {
return;
}
- this.handler = await this.getHandler();
-
this.$findBox.show();
this.$input.focus();
- this.$totalFound.text(0);
- this.$currentFound.text(0);
-
- const searchTerm = await this.handler.getInitialSearchTerm();
+ this.handler = await this.getHandler();
- this.$input.val(searchTerm || "");
+ const isAlreadyVisible = this.$findBox.is(":visible");
- // Directly perform the search if there's some text to
- // find, without delaying or waiting for enter
- if (searchTerm !== "") {
+ if (isAlreadyVisible) {
this.$input.select();
- await this.performFind();
+ } else {
+ this.$totalFound.text(0);
+ this.$currentFound.text(0);
+ const searchTerm = await this.handler.getInitialSearchTerm();
+ this.$input.val(searchTerm || "");
+ if (searchTerm !== "") {
+ this.$input.select();
+ await this.performFind();
+ }
}
}