feat(dashboard) modal search autofocus (#9038)
**What** - autofocus search input on route modal that have tables --- CLOSES CC-132
This commit is contained in:
1 parent
d398009d3f
commit
28dc8d4d17
17 files changed
+28
-19
No files matched your search
+7
-2
@@ -4,7 +4,7 @@ import { DataTableOrderBy } from "../data-table-order-by"
|
|||||||
import { DataTableSearch } from "../data-table-search"
|
import { DataTableSearch } from "../data-table-search"
|
||||||
|
|
||||||
export interface DataTableQueryProps {
|
export interface DataTableQueryProps {
|
||||||
search?: boolean
|
search?: boolean | "autofocus"
|
||||||
orderBy?: (string | number)[]
|
orderBy?: (string | number)[]
|
||||||
filters?: Filter[]
|
filters?: Filter[]
|
||||||
prefix?: string
|
prefix?: string
|
||||||
@@ -25,7 +25,12 @@ export const DataTableQuery = ({
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="flex shrink-0 items-center gap-x-2">
|
<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} />}
|
{orderBy && <DataTableOrderBy keys={orderBy} prefix={prefix} />}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+3
@@ -8,11 +8,13 @@ import { useSelectedParams } from "../hooks"
|
|||||||
type DataTableSearchProps = {
|
type DataTableSearchProps = {
|
||||||
placeholder?: string
|
placeholder?: string
|
||||||
prefix?: string
|
prefix?: string
|
||||||
|
autofocus?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DataTableSearch = ({
|
export const DataTableSearch = ({
|
||||||
placeholder,
|
placeholder,
|
||||||
prefix,
|
prefix,
|
||||||
|
autofocus,
|
||||||
}: DataTableSearchProps) => {
|
}: DataTableSearchProps) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const placeholderText = placeholder || t("general.search")
|
const placeholderText = placeholder || t("general.search")
|
||||||
@@ -50,6 +52,7 @@ export const DataTableSearch = ({
|
|||||||
name="q"
|
name="q"
|
||||||
type="search"
|
type="search"
|
||||||
size="small"
|
size="small"
|
||||||
|
autoFocus={autofocus}
|
||||||
defaultValue={query?.[0] || undefined}
|
defaultValue={query?.[0] || undefined}
|
||||||
onChange={debouncedOnChange}
|
onChange={debouncedOnChange}
|
||||||
placeholder={placeholderText}
|
placeholder={placeholderText}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ export const DataTable = <TData,>({
|
|||||||
<TableSkeleton
|
<TableSkeleton
|
||||||
layout={layout}
|
layout={layout}
|
||||||
rowCount={pageSize}
|
rowCount={pageSize}
|
||||||
search={search}
|
search={!!search}
|
||||||
filters={!!filters?.length}
|
filters={!!filters?.length}
|
||||||
orderBy={!!orderBy?.length}
|
orderBy={!!orderBy?.length}
|
||||||
pagination={!!pagination}
|
pagination={!!pagination}
|
||||||
|
|||||||
+1
-1
@@ -142,7 +142,7 @@ export const ApiKeySalesChannelsForm = ({
|
|||||||
count={count}
|
count={count}
|
||||||
pageSize={PAGE_SIZE}
|
pageSize={PAGE_SIZE}
|
||||||
pagination
|
pagination
|
||||||
search
|
search="autofocus"
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
queryObject={raw}
|
queryObject={raw}
|
||||||
orderBy={["name", "created_at", "updated_at"]}
|
orderBy={["name", "created_at", "updated_at"]}
|
||||||
|
|||||||
+1
-1
@@ -142,7 +142,7 @@ export const AddCampaignPromotionsForm = ({
|
|||||||
queryObject={raw}
|
queryObject={raw}
|
||||||
layout="fill"
|
layout="fill"
|
||||||
pagination
|
pagination
|
||||||
search
|
search="autofocus"
|
||||||
noRecords={{
|
noRecords={{
|
||||||
message: t("campaigns.promotions.add.list.noRecordsMessage"),
|
message: t("campaigns.promotions.add.list.noRecordsMessage"),
|
||||||
}}
|
}}
|
||||||
|
|||||||
+1
-1
@@ -171,7 +171,7 @@ export const EditCategoryProductsForm = ({
|
|||||||
isLoading={isPending}
|
isLoading={isPending}
|
||||||
layout="fill"
|
layout="fill"
|
||||||
pagination
|
pagination
|
||||||
search
|
search="autofocus"
|
||||||
/>
|
/>
|
||||||
</RouteFocusModal.Body>
|
</RouteFocusModal.Body>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
+1
-1
@@ -179,7 +179,7 @@ export const AddProductsToCollectionForm = ({
|
|||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
layout="fill"
|
layout="fill"
|
||||||
pagination
|
pagination
|
||||||
search
|
search="autofocus"
|
||||||
/>
|
/>
|
||||||
</RouteFocusModal.Body>
|
</RouteFocusModal.Body>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
+1
-1
@@ -168,7 +168,7 @@ export const AddCustomersForm = ({
|
|||||||
]}
|
]}
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
layout="fill"
|
layout="fill"
|
||||||
search
|
search="autofocus"
|
||||||
queryObject={raw}
|
queryObject={raw}
|
||||||
noRecords={{
|
noRecords={{
|
||||||
message: t("customerGroups.customers.add.list.noRecordsMessage"),
|
message: t("customerGroups.customers.add.list.noRecordsMessage"),
|
||||||
|
|||||||
+1
-1
@@ -180,7 +180,7 @@ export const AddCustomerGroupsForm = ({
|
|||||||
orderBy={["name", "created_at", "updated_at"]}
|
orderBy={["name", "created_at", "updated_at"]}
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
layout="fill"
|
layout="fill"
|
||||||
search
|
search="autofocus"
|
||||||
queryObject={raw}
|
queryObject={raw}
|
||||||
noRecords={{
|
noRecords={{
|
||||||
message: t("customers.groups.add.list.noRecordsMessage"),
|
message: t("customers.groups.add.list.noRecordsMessage"),
|
||||||
|
|||||||
+1
-1
@@ -130,7 +130,7 @@ export const LocationEditFulfillmentProvidersForm = ({
|
|||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
count={count}
|
count={count}
|
||||||
filters={filters}
|
filters={filters}
|
||||||
search
|
search="autofocus"
|
||||||
pagination
|
pagination
|
||||||
orderBy={["id", "created_at", "updated_at"]}
|
orderBy={["id", "created_at", "updated_at"]}
|
||||||
queryObject={raw}
|
queryObject={raw}
|
||||||
|
|||||||
+1
-1
@@ -144,7 +144,7 @@ export const LocationEditSalesChannelsForm = ({
|
|||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
count={count}
|
count={count}
|
||||||
filters={filters}
|
filters={filters}
|
||||||
search
|
search="autofocus"
|
||||||
pagination
|
pagination
|
||||||
orderBy={["name", "created_at", "updated_at"]}
|
orderBy={["name", "created_at", "updated_at"]}
|
||||||
queryObject={raw}
|
queryObject={raw}
|
||||||
|
|||||||
+1
-1
@@ -140,7 +140,7 @@ export const EditSalesChannelsForm = ({
|
|||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
count={count}
|
count={count}
|
||||||
filters={filters}
|
filters={filters}
|
||||||
search
|
search="autofocus"
|
||||||
pagination
|
pagination
|
||||||
orderBy={["name", "created_at", "updated_at"]}
|
orderBy={["name", "created_at", "updated_at"]}
|
||||||
queryObject={raw}
|
queryObject={raw}
|
||||||
|
|||||||
+1
-1
@@ -146,7 +146,7 @@ export const AddCountriesForm = ({ region }: AddCountriesFormProps) => {
|
|||||||
columns={columns}
|
columns={columns}
|
||||||
pageSize={PAGE_SIZE}
|
pageSize={PAGE_SIZE}
|
||||||
count={count}
|
count={count}
|
||||||
search
|
search="autofocus"
|
||||||
pagination
|
pagination
|
||||||
layout="fill"
|
layout="fill"
|
||||||
orderBy={["name", "code"]}
|
orderBy={["name", "code"]}
|
||||||
|
|||||||
+1
-1
@@ -419,7 +419,7 @@ export const CreateRegionForm = ({
|
|||||||
pageSize={PAGE_SIZE}
|
pageSize={PAGE_SIZE}
|
||||||
orderBy={["name", "code"]}
|
orderBy={["name", "code"]}
|
||||||
pagination
|
pagination
|
||||||
search
|
search="autofocus"
|
||||||
layout="fill"
|
layout="fill"
|
||||||
queryObject={raw}
|
queryObject={raw}
|
||||||
prefix={PREFIX}
|
prefix={PREFIX}
|
||||||
|
|||||||
+1
-1
@@ -152,7 +152,7 @@ export const AddProductsToSalesChannelForm = ({
|
|||||||
queryObject={raw}
|
queryObject={raw}
|
||||||
layout="fill"
|
layout="fill"
|
||||||
pagination
|
pagination
|
||||||
search
|
search="autofocus"
|
||||||
noRecords={{
|
noRecords={{
|
||||||
message: t("salesChannels.products.add.list.noRecordsMessage"),
|
message: t("salesChannels.products.add.list.noRecordsMessage"),
|
||||||
}}
|
}}
|
||||||
|
|||||||
+1
-1
@@ -199,7 +199,7 @@ export const AddCurrenciesForm = ({
|
|||||||
columns={columns}
|
columns={columns}
|
||||||
layout="fill"
|
layout="fill"
|
||||||
pagination
|
pagination
|
||||||
search
|
search="autofocus"
|
||||||
prefix={PREFIX}
|
prefix={PREFIX}
|
||||||
orderBy={["code", "name"]}
|
orderBy={["code", "name"]}
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
|
|||||||
+4
-3
@@ -39,8 +39,9 @@ const InviteUserSchema = zod.object({
|
|||||||
|
|
||||||
const PAGE_SIZE = 10
|
const PAGE_SIZE = 10
|
||||||
const PREFIX = "usr_invite"
|
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 = () => {
|
export const InviteUserForm = () => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
@@ -163,7 +164,7 @@ export const InviteUserForm = () => {
|
|||||||
pageSize={PAGE_SIZE}
|
pageSize={PAGE_SIZE}
|
||||||
prefix={PREFIX}
|
prefix={PREFIX}
|
||||||
pagination
|
pagination
|
||||||
search
|
search="autofocus"
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
queryObject={raw}
|
queryObject={raw}
|
||||||
orderBy={["email", "created_at", "updated_at"]}
|
orderBy={["email", "created_at", "updated_at"]}
|
||||||
|
|||||||
Reference in new issue
Block a user