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}
|
||||
|
||||
@@ -142,7 +142,7 @@ export const ApiKeySalesChannelsForm = ({
|
||||
count={count}
|
||||
pageSize={PAGE_SIZE}
|
||||
pagination
|
||||
search
|
||||
search="autofocus"
|
||||
isLoading={isLoading}
|
||||
queryObject={raw}
|
||||
orderBy={["name", "created_at", "updated_at"]}
|
||||
|
||||
@@ -142,7 +142,7 @@ export const AddCampaignPromotionsForm = ({
|
||||
queryObject={raw}
|
||||
layout="fill"
|
||||
pagination
|
||||
search
|
||||
search="autofocus"
|
||||
noRecords={{
|
||||
message: t("campaigns.promotions.add.list.noRecordsMessage"),
|
||||
}}
|
||||
|
||||
@@ -171,7 +171,7 @@ export const EditCategoryProductsForm = ({
|
||||
isLoading={isPending}
|
||||
layout="fill"
|
||||
pagination
|
||||
search
|
||||
search="autofocus"
|
||||
/>
|
||||
</RouteFocusModal.Body>
|
||||
</form>
|
||||
|
||||
@@ -179,7 +179,7 @@ export const AddProductsToCollectionForm = ({
|
||||
isLoading={isLoading}
|
||||
layout="fill"
|
||||
pagination
|
||||
search
|
||||
search="autofocus"
|
||||
/>
|
||||
</RouteFocusModal.Body>
|
||||
</form>
|
||||
|
||||
@@ -168,7 +168,7 @@ export const AddCustomersForm = ({
|
||||
]}
|
||||
isLoading={isLoading}
|
||||
layout="fill"
|
||||
search
|
||||
search="autofocus"
|
||||
queryObject={raw}
|
||||
noRecords={{
|
||||
message: t("customerGroups.customers.add.list.noRecordsMessage"),
|
||||
|
||||
@@ -180,7 +180,7 @@ export const AddCustomerGroupsForm = ({
|
||||
orderBy={["name", "created_at", "updated_at"]}
|
||||
isLoading={isLoading}
|
||||
layout="fill"
|
||||
search
|
||||
search="autofocus"
|
||||
queryObject={raw}
|
||||
noRecords={{
|
||||
message: t("customers.groups.add.list.noRecordsMessage"),
|
||||
|
||||
@@ -130,7 +130,7 @@ export const LocationEditFulfillmentProvidersForm = ({
|
||||
isLoading={isLoading}
|
||||
count={count}
|
||||
filters={filters}
|
||||
search
|
||||
search="autofocus"
|
||||
pagination
|
||||
orderBy={["id", "created_at", "updated_at"]}
|
||||
queryObject={raw}
|
||||
|
||||
@@ -144,7 +144,7 @@ export const LocationEditSalesChannelsForm = ({
|
||||
isLoading={isLoading}
|
||||
count={count}
|
||||
filters={filters}
|
||||
search
|
||||
search="autofocus"
|
||||
pagination
|
||||
orderBy={["name", "created_at", "updated_at"]}
|
||||
queryObject={raw}
|
||||
|
||||
@@ -140,7 +140,7 @@ export const EditSalesChannelsForm = ({
|
||||
isLoading={isLoading}
|
||||
count={count}
|
||||
filters={filters}
|
||||
search
|
||||
search="autofocus"
|
||||
pagination
|
||||
orderBy={["name", "created_at", "updated_at"]}
|
||||
queryObject={raw}
|
||||
|
||||
@@ -146,7 +146,7 @@ export const AddCountriesForm = ({ region }: AddCountriesFormProps) => {
|
||||
columns={columns}
|
||||
pageSize={PAGE_SIZE}
|
||||
count={count}
|
||||
search
|
||||
search="autofocus"
|
||||
pagination
|
||||
layout="fill"
|
||||
orderBy={["name", "code"]}
|
||||
|
||||
@@ -419,7 +419,7 @@ export const CreateRegionForm = ({
|
||||
pageSize={PAGE_SIZE}
|
||||
orderBy={["name", "code"]}
|
||||
pagination
|
||||
search
|
||||
search="autofocus"
|
||||
layout="fill"
|
||||
queryObject={raw}
|
||||
prefix={PREFIX}
|
||||
|
||||
@@ -152,7 +152,7 @@ export const AddProductsToSalesChannelForm = ({
|
||||
queryObject={raw}
|
||||
layout="fill"
|
||||
pagination
|
||||
search
|
||||
search="autofocus"
|
||||
noRecords={{
|
||||
message: t("salesChannels.products.add.list.noRecordsMessage"),
|
||||
}}
|
||||
|
||||
@@ -199,7 +199,7 @@ export const AddCurrenciesForm = ({
|
||||
columns={columns}
|
||||
layout="fill"
|
||||
pagination
|
||||
search
|
||||
search="autofocus"
|
||||
prefix={PREFIX}
|
||||
orderBy={["code", "name"]}
|
||||
isLoading={isLoading}
|
||||
|
||||
@@ -39,8 +39,9 @@ const InviteUserSchema = zod.object({
|
||||
|
||||
const PAGE_SIZE = 10
|
||||
const PREFIX = "usr_invite"
|
||||
const INVITE_URL = `${window.location.origin}${__BASE__ === "/" ? "" : __BASE__}/invite?token=`
|
||||
|
||||
const INVITE_URL = `${window.location.origin}${
|
||||
__BASE__ === "/" ? "" : __BASE__
|
||||
}/invite?token=`
|
||||
|
||||
export const InviteUserForm = () => {
|
||||
const { t } = useTranslation()
|
||||
@@ -163,7 +164,7 @@ export const InviteUserForm = () => {
|
||||
pageSize={PAGE_SIZE}
|
||||
prefix={PREFIX}
|
||||
pagination
|
||||
search
|
||||
search="autofocus"
|
||||
isLoading={isLoading}
|
||||
queryObject={raw}
|
||||
orderBy={["email", "created_at", "updated_at"]}
|
||||
|
||||
Reference in New Issue
Block a user