Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Reset query after modal close
dominik-zeglen9fcef1ac0596
diff --git a/saleor/static/dashboard-next/components/AssignAttributeDialog/AssignAttributeDialog.tsx b/saleor/static/dashboard-next/components/AssignAttributeDialog/AssignAttributeDialog.tsxindex 27b1be23d4..d20a5f3fde 100644--- a/saleor/static/dashboard-next/components/AssignAttributeDialog/AssignAttributeDialog.tsx+++ b/saleor/static/dashboard-next/components/AssignAttributeDialog/AssignAttributeDialog.tsx@@ -71,9 +71,11 @@ const AssignAttributeDialog: React.FC<AssignAttributeDialogProps> = ({onToggle}: AssignAttributeDialogProps) => {const classes = useStyles({});- const [query, onQueryChange] = useSearchQuery(onFetch);+ const [query, onQueryChange, resetQuery] = useSearchQuery(onFetch);const errors = useModalDialogErrors(apiErrors, open);+ React.useEffect(resetQuery, [open]);+return (<Dialog onClose={onClose} open={open} fullWidth maxWidth="sm"><DialogTitle>{i18n.t("Assign Attribute")}</DialogTitle>diff --git a/saleor/static/dashboard-next/hooks/useSearchQuery.ts b/saleor/static/dashboard-next/hooks/useSearchQuery.tsindex af33288489..eac204bfc0 100644--- a/saleor/static/dashboard-next/hooks/useSearchQuery.ts+++ b/saleor/static/dashboard-next/hooks/useSearchQuery.ts@@ -2,7 +2,7 @@ import React from "react";import { ChangeEvent } from "@saleor/hooks/useForm";-export type UseSearchQuery = [string, (event: ChangeEvent) => void];+export type UseSearchQuery = [string, (event: ChangeEvent) => void, () => void];function useSearchQuery(onFetch: (query: string) => void,initial?: string@@ -15,7 +15,15 @@ function useSearchQuery(setQuery(value);};- return [query, change];+ const reset = () =>+ change({+ target: {+ name: "",+ value: initial || ""+ }+ });++ return [query, change, reset];}export default useSearchQuery;