Sets correct Sidebar view when adding a product

If the last selected view on mobile was the menu, it was shown instead of the cart when adding a product.
This commit is contained in:
ltueth 2022-03-12 22:44:35 +01:00 committed by GitHub
parent 7cd1910f82
commit 620f2b0b41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,7 +17,7 @@ interface ProductSidebarProps {
const ProductSidebar: FC<ProductSidebarProps> = ({ product, className }) => { const ProductSidebar: FC<ProductSidebarProps> = ({ product, className }) => {
const addItem = useAddItem() const addItem = useAddItem()
const { openSidebar } = useUI() const { openSidebar, setSidebarView } = useUI()
const [loading, setLoading] = useState(false) const [loading, setLoading] = useState(false)
const [selectedOptions, setSelectedOptions] = useState<SelectedOptions>({}) const [selectedOptions, setSelectedOptions] = useState<SelectedOptions>({})
@ -33,6 +33,7 @@ const ProductSidebar: FC<ProductSidebarProps> = ({ product, className }) => {
productId: String(product.id), productId: String(product.id),
variantId: String(variant ? variant.id : product.variants[0]?.id), variantId: String(variant ? variant.id : product.variants[0]?.id),
}) })
setSidebarView('CART_VIEW')
openSidebar() openSidebar()
setLoading(false) setLoading(false)
} catch (err) { } catch (err) {