ux: ignore initial/trailing spaces in search
Massimo Melina committed
Apr 20, 2023 at 10:53 UTC
6d7e181c327541186737168953acfeac9b55179a
1 file changed
+6
-3
frontend/src/dialog.ts
+6
-3
@@ -8,8 +8,8 @@ import { useInterval } from 'usehooks-ts'
8
import { t } from './i18n'
9
export * from '@hfs/shared/dialogs'
10
11
-interface PromptOptions extends Partial<DialogOptions> { def?:string, type?:string }
12
-export async function promptDialog(msg: string, { def, type, ...rest }:PromptOptions={}) : Promise<string | null> {
11
+interface PromptOptions extends Partial<DialogOptions> { def?:string, type?:string, trim?: boolean }
12
+export async function promptDialog(msg: string, { def, type, trim=true, ...rest }:PromptOptions={}) : Promise<string | null> {
13
return new Promise(resolve => newDialog({
14
className: 'dialog-prompt',
15
icon: '?',
@@ -48,7 +48,10 @@ export async function promptDialog(msg: string, { def, type, ...rest }:PromptOpt
48
)
49
50
function go() {
51
- closeDialog(ref.current?.value)
51
+ let res = ref.current?.value
52
+ if (trim)
53
+ res = res?.trim()
54
+ closeDialog(res)
55
}
56
}
57
}