feat(dashboard) modal search autofocus (#9038)
**What** - autofocus search input on route modal that have tables --- CLOSES CC-132
This commit is contained in:
@@ -4,7 +4,7 @@ import { DataTableOrderBy } from "../data-table-order-by"
|
||||
import { DataTableSearch } from "../data-table-search"
|
||||
|
||||
export interface DataTableQueryProps {
|
||||
search?: boolean
|
||||
search?: boolean | "autofocus"
|
||||
orderBy?: (string | number)[]
|
||||
filters?: Filter[]
|
||||
prefix?: string
|
||||
@@ -25,7 +25,12 @@ export const DataTableQuery = ({
|
||||
)}
|
||||
</div>
|
||||
<div className="flex shrink-0 items-center gap-x-2">
|
||||
{search && <DataTableSearch prefix={prefix} />}
|
||||
{search && (
|
||||
<DataTableSearch
|
||||
prefix={prefix}
|
||||
autofocus={search === "autofocus"}
|
||||
/>
|
||||
)}
|
||||
{orderBy && <DataTableOrderBy keys={orderBy} prefix={prefix} />}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -8,11 +8,13 @@ import { useSelectedParams } from "../hooks"
|
||||
type DataTableSearchProps = {
|
||||
placeholder?: string
|
||||
prefix?: string
|
||||
autofocus?: boolean
|
||||
}
|
||||
|
||||
export const DataTableSearch = ({
|
||||
placeholder,
|
||||
prefix,
|
||||
autofocus,
|
||||
}: DataTableSearchProps) => {
|
||||
const { t } = useTranslation()
|
||||
const placeholderText = placeholder || t("general.search")
|
||||
@@ -50,6 +52,7 @@ export const DataTableSearch = ({
|
||||
name="q"
|
||||
type="search"
|
||||
size="small"
|
||||
autoFocus={autofocus}
|
||||
defaultValue={query?.[0] || undefined}
|
||||
onChange={debouncedOnChange}
|
||||
placeholder={placeholderText}
|
||||
|
||||
@@ -41,7 +41,7 @@ export const DataTable = <TData,>({
|
||||
<TableSkeleton
|
||||
layout={layout}
|
||||
rowCount={pageSize}
|
||||
search={search}
|
||||
search={!!search}
|
||||
filters={!!filters?.length}
|
||||
orderBy={!!orderBy?.length}
|
||||
pagination={!!pagination}
|
||||
|
||||
Reference in New Issue
Block a user