Using display options with layoutCandidates. Fixes #1831

This commit is contained in:
Francisco Hodge
2023-01-04 01:48:06 -05:00
parent 040d4fc40f
commit 5e1df22e59
10 changed files with 20 additions and 12 deletions
+5 -2
View File
@@ -5,16 +5,19 @@ import {
CandidateBoxParams,
CandidateBoxRenderParams,
CandidateBoxShowParams,
KeyboardOptions,
} from "./../interfaces";
class CandidateBox {
utilities: Utilities;
options: KeyboardOptions;
candidateBoxElement!: HTMLDivElement;
pageIndex = 0;
pageSize;
constructor({ utilities }: CandidateBoxParams) {
constructor({ utilities, options }: CandidateBoxParams) {
this.utilities = utilities;
this.options = options;
Utilities.bindMethods(CandidateBox, this);
this.pageSize = this.utilities.getOptions().layoutCandidatesPageSize || 5;
}
@@ -82,7 +85,7 @@ class CandidateBox {
};
candidateListLIElement.className = "hg-candidate-box-list-item";
candidateListLIElement.textContent = candidateListItem;
candidateListLIElement.textContent = this.options.display?.[candidateListItem] || candidateListItem;
candidateListLIElement.onclick = (e = getMouseEvent()) =>
onItemSelected(candidateListItem, e);
+2
View File
@@ -215,6 +215,7 @@ class SimpleKeyboard {
this.candidateBox = this.options.enableLayoutCandidates
? new CandidateBox({
utilities: this.utilities,
options: this.options,
})
: null;
@@ -878,6 +879,7 @@ class SimpleKeyboard {
this.candidateBox.destroy();
this.candidateBox = new CandidateBox({
utilities: this.utilities,
options: this.options,
});
}
}
+2 -1
View File
@@ -22,7 +22,8 @@ export interface KeyboardInput {
}
export type CandidateBoxParams = {
utilities: Utilities
utilities: Utilities,
options: KeyboardOptions
}
export type CandidateBoxShowParams = {