Skip to content

Commit 9307954

Browse files
committed
fix: store selector don't re-navigate if already in the store
1 parent b25b1b5 commit 9307954

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

static/js/publisher/components/StoreSelector/StoreSelector.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { brandStoresState } from "../../state/brandStoreState";
66
import ComboBox from "../ComboBox/ComboBox";
77

88
function StoreSelector(): React.JSX.Element {
9-
const { id } = useParams();
9+
const { id: storeId } = useParams();
1010
const navigate = useNavigate();
1111
const brandStoresList = useAtomValue(brandStoresState);
1212

@@ -22,14 +22,15 @@ function StoreSelector(): React.JSX.Element {
2222
return (
2323
<ComboBox
2424
options={comboBoxOptions}
25-
value={id ?? ""}
25+
value={storeId ?? ""}
2626
label="Select store"
2727
placeholder="Select store"
2828
labelClassName="u-off-screen"
2929
required
30-
onChange={(storeId) => {
31-
if (!storeId) return;
32-
navigate(`/admin/${storeId}/snaps`);
30+
onChange={(newStoreId) => {
31+
if (!newStoreId) return;
32+
if (storeId === newStoreId) return;
33+
navigate(`/admin/${newStoreId}/snaps`);
3334
}}
3435
/>
3536
);

0 commit comments

Comments
 (0)