Skip to content

Commit

Permalink
Fixed Setting Track Type when Picking from AutoSuggest (#394)
Browse files Browse the repository at this point in the history
Co-authored-by: bloodynine <corvetteclass@proton.me>
  • Loading branch information
bloodynine and bloodynine authored Jul 10, 2024
1 parent 4d12db2 commit c06373a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/tracks/progress-create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,20 +115,19 @@ export class ProgressTrackCreateModal extends Modal {
"What kind of track is this? (e.g., Vow, Connection)",
);

new GenericTextSuggest(this.app, search.inputEl, [
"Vow",
"Connection",
"Combat",
"Scene Challenge",
"Expedition",
]);
new GenericTextSuggest(
this.app,
search.inputEl,
["Vow", "Connection", "Combat", "Scene Challenge", "Expedition"],
(val) => {
search.setValue(val);
search.onChanged();
},
);

search.onChange((value) => {
this.result.trackType = value;
});
search.inputEl.addEventListener("change", () => {
this.result.trackType = search.inputEl.value;
});
});

new Setting(contentEl)
Expand Down
2 changes: 2 additions & 0 deletions src/utils/ui/settings/generic-text-suggest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export class GenericTextSuggest extends AbstractInputSuggest<
app: App,
inputEl: HTMLInputElement,
public readonly items: string[],
private onSelectCallBack: (value: string) => void = () => {},
) {
super(app, inputEl);
}
Expand Down Expand Up @@ -53,6 +54,7 @@ export class GenericTextSuggest extends AbstractInputSuggest<

selectSuggestion({ item }: FuzzyMatch<string>): void {
this.setValue(item);
this.onSelectCallBack(item);
this.close();
}
}

0 comments on commit c06373a

Please sign in to comment.