@graphcommerce/magento-product 11.0.0-canary.57 → 11.0.0-canary.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 11.0.0-canary.58
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#2718](https://github.com/graphcommerce-org/graphcommerce/pull/2718) [`d6145eb`](https://github.com/graphcommerce-org/graphcommerce/commit/d6145ebbabc4f3cad3bbc78e5f32794098577223) - Fix the product list pagination scrolling to the products before the next page was loaded. The shopper saw the products of the previous page until the new products arrived. The pagination loads the products first and then scrolls, the same as the filters. ([@bramvanderholst](https://github.com/bramvanderholst))
|
|
8
|
+
|
|
3
9
|
## 11.0.0-canary.57
|
|
4
10
|
|
|
5
11
|
### Major Changes
|
|
@@ -45,6 +45,7 @@ export type ProductFiltersProContext = DataProps & {
|
|
|
45
45
|
*/
|
|
46
46
|
params: ProductFilterParams
|
|
47
47
|
submit: (e?: BaseSyntheticEvent<object, any, any> | undefined) => Promise<unknown>
|
|
48
|
+
handleSubmit: FilterFormProviderProps['handleSubmit']
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
const FilterFormContext = createContext<ProductFiltersProContext | null>(null)
|
|
@@ -145,13 +146,14 @@ export function ProductFiltersPro(props: FilterFormProviderProps) {
|
|
|
145
146
|
form,
|
|
146
147
|
params: defaultValues,
|
|
147
148
|
submit,
|
|
149
|
+
handleSubmit,
|
|
148
150
|
appliedAggregations,
|
|
149
151
|
filterTypes,
|
|
150
152
|
aggregations: aggregations ?? appliedAggregations,
|
|
151
153
|
}
|
|
152
154
|
globalFormContextRef.current = ctx
|
|
153
155
|
return ctx
|
|
154
|
-
}, [form, defaultValues, submit, appliedAggregations, filterTypes, aggregations])
|
|
156
|
+
}, [form, defaultValues, submit, handleSubmit, appliedAggregations, filterTypes, aggregations])
|
|
155
157
|
|
|
156
158
|
// When the component unmounts, we want to clear the global filter form
|
|
157
159
|
useEffect(
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { productListPaginationVariant } from '@graphcommerce/next-config/config'
|
|
2
|
+
import type { LinkProps } from '@graphcommerce/next-ui'
|
|
2
3
|
import { NextLink, Pagination, PaginationExtended } from '@graphcommerce/next-ui'
|
|
3
4
|
import type { PaginationProps } from '@mui/material'
|
|
4
5
|
import { Link } from '@mui/material'
|
|
6
|
+
import { useRouter } from 'next/router'
|
|
5
7
|
import { productListLink } from '../../hooks/useProductListLink'
|
|
8
|
+
import { useProductFiltersPro } from '../ProductFiltersPro/ProductFiltersPro'
|
|
6
9
|
import type { ProductListParams } from '../ProductListItems/filterTypes'
|
|
10
|
+
import { toFilterParams } from '../ProductListItems/filterTypes'
|
|
7
11
|
import type { ProductListPaginationFragment } from './ProductListPagination.gql'
|
|
8
12
|
|
|
9
13
|
export type ProductPaginationProps = ProductListPaginationFragment &
|
|
@@ -16,8 +20,22 @@ export function ProductListPagination({
|
|
|
16
20
|
params,
|
|
17
21
|
...paginationProps
|
|
18
22
|
}: ProductPaginationProps) {
|
|
23
|
+
const router = useRouter()
|
|
24
|
+
const handleSubmit = useProductFiltersPro(true)?.handleSubmit
|
|
25
|
+
|
|
19
26
|
if (!page_info || !page_info.total_pages || !page_info.current_page) return null
|
|
20
27
|
|
|
28
|
+
// Loads the products before the URL changes, so the page scrolls to the loaded products.
|
|
29
|
+
const onNavigate = (page: number | null): LinkProps['onNavigate'] =>
|
|
30
|
+
handleSubmit &&
|
|
31
|
+
((e) => {
|
|
32
|
+
e.preventDefault()
|
|
33
|
+
const path = `${productListLink({ ...params, currentPage: page })}${page === 1 ? '' : '#products'}`
|
|
34
|
+
void handleSubmit({ ...toFilterParams(params), currentPage: page ?? 1 }, async (shallow) => {
|
|
35
|
+
await router.push(path, path, { shallow, scroll: true })
|
|
36
|
+
})
|
|
37
|
+
})
|
|
38
|
+
|
|
21
39
|
if (productListPaginationVariant !== 'EXTENDED') {
|
|
22
40
|
return (
|
|
23
41
|
<Pagination
|
|
@@ -31,6 +49,7 @@ export function ProductListPagination({
|
|
|
31
49
|
href={`${productListLink({ ...params, currentPage: btnProps.page })}${suffix}`}
|
|
32
50
|
component={NextLink}
|
|
33
51
|
shallow
|
|
52
|
+
onNavigate={onNavigate(btnProps.page)}
|
|
34
53
|
color='inherit'
|
|
35
54
|
>
|
|
36
55
|
{icon}
|
|
@@ -50,6 +69,7 @@ export function ProductListPagination({
|
|
|
50
69
|
paginationHref={({ page }) =>
|
|
51
70
|
`${productListLink({ ...params, currentPage: page })}${page === 1 ? '' : '#products'}`
|
|
52
71
|
}
|
|
72
|
+
onNavigate={({ page }) => onNavigate(page)}
|
|
53
73
|
{...paginationProps}
|
|
54
74
|
/>
|
|
55
75
|
)
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphcommerce/magento-product",
|
|
3
3
|
"homepage": "https://www.graphcommerce.org/",
|
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce",
|
|
5
|
-
"version": "11.0.0-canary.
|
|
5
|
+
"version": "11.0.0-canary.58",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
|
@@ -18,18 +18,18 @@
|
|
|
18
18
|
"typescript": "6.0.3"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
|
-
"@graphcommerce/ecommerce-ui": "^11.0.0-canary.
|
|
22
|
-
"@graphcommerce/eslint-config-pwa": "^11.0.0-canary.
|
|
23
|
-
"@graphcommerce/framer-next-pages": "^11.0.0-canary.
|
|
24
|
-
"@graphcommerce/framer-scroller": "^11.0.0-canary.
|
|
25
|
-
"@graphcommerce/graphql": "^11.0.0-canary.
|
|
26
|
-
"@graphcommerce/graphql-mesh": "^11.0.0-canary.
|
|
27
|
-
"@graphcommerce/image": "^11.0.0-canary.
|
|
28
|
-
"@graphcommerce/magento-cart": "^11.0.0-canary.
|
|
29
|
-
"@graphcommerce/magento-store": "^11.0.0-canary.
|
|
30
|
-
"@graphcommerce/next-ui": "^11.0.0-canary.
|
|
31
|
-
"@graphcommerce/prettier-config-pwa": "^11.0.0-canary.
|
|
32
|
-
"@graphcommerce/typescript-config-pwa": "^11.0.0-canary.
|
|
21
|
+
"@graphcommerce/ecommerce-ui": "^11.0.0-canary.58",
|
|
22
|
+
"@graphcommerce/eslint-config-pwa": "^11.0.0-canary.58",
|
|
23
|
+
"@graphcommerce/framer-next-pages": "^11.0.0-canary.58",
|
|
24
|
+
"@graphcommerce/framer-scroller": "^11.0.0-canary.58",
|
|
25
|
+
"@graphcommerce/graphql": "^11.0.0-canary.58",
|
|
26
|
+
"@graphcommerce/graphql-mesh": "^11.0.0-canary.58",
|
|
27
|
+
"@graphcommerce/image": "^11.0.0-canary.58",
|
|
28
|
+
"@graphcommerce/magento-cart": "^11.0.0-canary.58",
|
|
29
|
+
"@graphcommerce/magento-store": "^11.0.0-canary.58",
|
|
30
|
+
"@graphcommerce/next-ui": "^11.0.0-canary.58",
|
|
31
|
+
"@graphcommerce/prettier-config-pwa": "^11.0.0-canary.58",
|
|
32
|
+
"@graphcommerce/typescript-config-pwa": "^11.0.0-canary.58",
|
|
33
33
|
"@lingui/core": "^6",
|
|
34
34
|
"@lingui/react": "^6",
|
|
35
35
|
"@mui/material": "^7.0.0",
|