Skip to content

Commit

Permalink
Fix assign attribute value dialogs showing previous search results (#…
Browse files Browse the repository at this point in the history
…4400)

* Reset query onClose

* Add changeset
  • Loading branch information
Droniu authored Nov 3, 2023
1 parent b7c2a96 commit 873954f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/quiet-wasps-sing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---

Fix assign attribute value dialogs showing previous search results
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,21 @@ const AssignContainerDialog: React.FC<AssignContainerDialogProps> = props => {
const classes = useStyles(props);
const scrollableDialogClasses = useScrollableDialogStyle({});

const [query, onQueryChange] = useSearchQuery(onFetch);
const [query, onQueryChange, queryReset] = useSearchQuery(onFetch);
const [selectedContainers, setSelectedContainers] = React.useState<
Container[]
>([]);

const handleSubmit = () => onSubmit(selectedContainers);

const handleClose = () => {
queryReset();
onClose();
};

return (
<Dialog
onClose={onClose}
onClose={handleClose}
open={open}
classes={{ paper: scrollableDialogClasses.dialog }}
fullWidth
Expand Down
7 changes: 6 additions & 1 deletion src/components/AssignProductDialog/AssignProductDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,14 @@ const AssignProductDialog: React.FC<AssignProductDialogProps> = props => {
}));
};

const handleClose = () => {
queryReset();
onClose();
};

return (
<Dialog
onClose={onClose}
onClose={handleClose}
open={open}
classes={{ paper: scrollableDialogClasses.dialog }}
fullWidth
Expand Down
9 changes: 7 additions & 2 deletions src/components/AssignVariantDialog/AssignVariantDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const AssignVariantDialog: React.FC<AssignVariantDialogProps> = props => {
const scrollableDialogClasses = useScrollableDialogStyle({});

const intl = useIntl();
const [query, onQueryChange] = useSearchQuery(onFetch);
const [query, onQueryChange, queryReset] = useSearchQuery(onFetch);
const [variants, setVariants] = React.useState<VariantWithProductLabel[]>([]);

const productChoices =
Expand All @@ -97,9 +97,14 @@ const AssignVariantDialog: React.FC<AssignVariantDialogProps> = props => {
})),
);

const handleClose = () => {
queryReset();
onClose();
};

return (
<Dialog
onClose={onClose}
onClose={handleClose}
open={open}
classes={{ paper: scrollableDialogClasses.dialog }}
fullWidth
Expand Down

0 comments on commit 873954f

Please sign in to comment.