generated from obsidianmd/obsidian-sample-plugin
-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: filtering in multi with uppercase
- Loading branch information
1 parent
101e972
commit fac67ea
Showing
1 changed file
with
21 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
import { TextInputSuggest } from "./suggest"; | ||
|
||
export class MultiSuggest extends TextInputSuggest<string> { | ||
content: Set<string>; | ||
content: Set<string>; | ||
|
||
constructor(input: HTMLInputElement, content: Set<string>, private onSelect: (value: string) => void) { | ||
super(app, input); | ||
this.content = content; | ||
} | ||
constructor(input: HTMLInputElement, content: Set<string>, private onSelect: (value: string) => void) { | ||
super(app, input); | ||
this.content = content; | ||
} | ||
|
||
getSuggestions(inputStr: string): string[] { | ||
const lowerCaseInputStr = inputStr.toLowerCase(); | ||
return [...this.content].filter((content) => | ||
content.contains(lowerCaseInputStr) | ||
); | ||
} | ||
getSuggestions(inputStr: string): string[] { | ||
const lowerCaseInputStr = inputStr.toLocaleLowerCase(); | ||
return [...this.content].filter((content) => | ||
content.toLocaleLowerCase().contains(lowerCaseInputStr) | ||
); | ||
} | ||
|
||
renderSuggestion(content: string, el: HTMLElement): void { | ||
el.setText(content); | ||
} | ||
renderSuggestion(content: string, el: HTMLElement): void { | ||
el.setText(content); | ||
} | ||
|
||
selectSuggestion(content: string): void { | ||
this.onSelect(content); | ||
this.inputEl.value = ""; | ||
// this.inputEl.trigger("blur"); | ||
this.inputEl.blur() | ||
this.close(); | ||
} | ||
selectSuggestion(content: string): void { | ||
this.onSelect(content); | ||
this.inputEl.value = ""; | ||
// this.inputEl.trigger("blur"); | ||
this.inputEl.blur() | ||
this.close(); | ||
} | ||
} |