aboutsummaryrefslogtreecommitdiff
path: root/ext/js/display/query-parser.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2024-02-02 21:33:47 -0500
committerGitHub <noreply@github.com>2024-02-03 02:33:47 +0000
commit6dc7e90f8d5679b0de298c820a5b88b93590ed31 (patch)
tree42616fb712c7a5a019cde592bd2980e5eb9a3539 /ext/js/display/query-parser.js
parent711520e9a04096dba3adb1f09c0865eda5fb587c (diff)
Fix auto hide search popup (#592)
* Remove return * Update searched event * Fix auto-hide search popup event not occuring * Add TODO * Split into multiple events
Diffstat (limited to 'ext/js/display/query-parser.js')
-rw-r--r--ext/js/display/query-parser.js35
1 files changed, 13 insertions, 22 deletions
diff --git a/ext/js/display/query-parser.js b/ext/js/display/query-parser.js
index daa298d2..6ec803a0 100644
--- a/ext/js/display/query-parser.js
+++ b/ext/js/display/query-parser.js
@@ -82,7 +82,8 @@ export class QueryParser extends EventDispatcher {
prepare() {
this._textScanner.prepare();
this._textScanner.on('clear', this._onTextScannerClear.bind(this));
- this._textScanner.on('searched', this._onSearched.bind(this));
+ this._textScanner.on('searchSuccess', this._onSearchSuccess.bind(this));
+ this._textScanner.on('searchError', this._onSearchError.bind(this));
this._queryParserModeSelect.addEventListener('change', this._onParserChange.bind(this), false);
}
@@ -147,39 +148,29 @@ export class QueryParser extends EventDispatcher {
}
/**
- * @param {import('text-scanner').SearchedEventDetails} e
+ * @param {import('text-scanner').EventArgument<'searchSuccess'>} details
*/
- _onSearched(e) {
- const {error} = e;
- if (error !== null) {
- log.error(error);
- return;
- }
-
- const {
- textScanner,
- type,
- dictionaryEntries,
- sentence,
- inputInfo,
- textSource,
- optionsContext
- } = e;
- if (type === null || dictionaryEntries === null || sentence === null || optionsContext === null) { return; }
-
+ _onSearchSuccess({type, dictionaryEntries, sentence, inputInfo, textSource, optionsContext}) {
this.trigger('searched', {
- textScanner,
+ textScanner: this._textScanner,
type,
dictionaryEntries,
sentence,
inputInfo,
textSource,
optionsContext,
- sentenceOffset: this._getSentenceOffset(e.textSource)
+ sentenceOffset: this._getSentenceOffset(textSource)
});
}
/**
+ * @param {import('text-scanner').EventArgument<'searchError'>} details
+ */
+ _onSearchError({error}) {
+ log.error(error);
+ }
+
+ /**
* @param {Event} e
*/
_onParserChange(e) {