Skip to content

Commit 2ad685b

Browse files
MytsVmaany
authored andcommitted
Add a placeholder (*) for unspecified RSE expression
1 parent 60444ca commit 2ad685b

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/component-library/Pages/RSE/ListRSE.tsx

+13-7
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,19 @@ import { TextInput } from "@/component-library/Input/TextInput";
1818
import { useState } from "react";
1919
import { Button } from "@/component-library/Button/Button";
2020

21+
const defaultRSEQuery = "*";
22+
2123
export const ListRSE = (
2224
props: {
2325
comdom: UseComDOM<RSEViewModel>
2426
setRSEQuery: (rseExpression: string) => void
2527
}
2628
) => {
2729

28-
const [rseSearchQuery, setRSESearchQuery] = useState<string>("")
30+
const [rseSearchQuery, setRSESearchQuery] = useState<string>(defaultRSEQuery)
31+
const setInputAsQuery = (searchPattern: string) => {
32+
setRSESearchQuery(searchPattern !== '' ? searchPattern : defaultRSEQuery)
33+
}
2934

3035
const columnHelper = createColumnHelper<RSEViewModel>()
3136
const tablecolumns = [
@@ -144,21 +149,22 @@ export const ListRSE = (
144149
RSE Search Pattern
145150
</label>
146151
<TextInput
147-
onBlur={(event: any) => { setRSESearchQuery(event.target.value) }}
148-
onEnterkey={async (e: any) => {
152+
onBlur={(event: any) => { setInputAsQuery(event.target.value) }}
153+
onEnterkey={(e) => {
149154
e.preventDefault()
150-
await props.setRSEQuery(e.target.value)
151-
setRSESearchQuery(e.target.value)
155+
setInputAsQuery(e.target.value)
156+
props.setRSEQuery(rseSearchQuery)
152157
props.comdom.start()
153158
}}
154159
id="rse-search-pattern"
160+
placeholder={defaultRSEQuery}
155161
/>
156162
<Button
157163
type="button"
158164
label="Search"
159-
onClick={async (e: any) => {
165+
onClick={(e: any) => {
160166
e.preventDefault()
161-
await props.setRSEQuery(rseSearchQuery)
167+
props.setRSEQuery(rseSearchQuery)
162168
props.comdom.start()
163169
}}
164170
className={twMerge(

0 commit comments

Comments
 (0)