@graphcommerce/magento-search 9.0.0-canary.58 → 9.0.0-canary.59

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
+ ## 9.0.0-canary.59
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2309](https://github.com/graphcommerce-org/graphcommerce/pull/2309) [`03e410f`](https://github.com/graphcommerce-org/graphcommerce/commit/03e410f7ad59ce94a6ff199809999e56ff8cc1f5) - Solve issue where the input field wouldn't open and wouldn't be focussed on render. ([@Renzovh](https://github.com/Renzovh))
8
+
3
9
  ## 9.0.0-canary.58
4
10
 
5
11
  ### Patch Changes
@@ -1,9 +1,9 @@
1
1
  import { IconSvg, iconSearch, showPageLoadIndicator } from '@graphcommerce/next-ui'
2
2
  import { Fab, FabProps } from '@mui/material'
3
- import { useMemo, useRef, useState } from 'react'
3
+ import dynamic from 'next/dynamic'
4
+ import { useMemo, useState } from 'react'
4
5
  import { ProductFiltersProSearchInputProps } from './ProductFiltersProSearchInput'
5
6
  import { useSearchPageAndParam } from './useSearchPageAndParam'
6
- import dynamic from 'next/dynamic'
7
7
 
8
8
  type ProductFiltersProSearchFieldProps = ProductFiltersProSearchInputProps & {
9
9
  fab?: FabProps
@@ -19,11 +19,10 @@ export function ProductFiltersProSearchField(props: ProductFiltersProSearchField
19
19
  const [searchPage] = useSearchPageAndParam()
20
20
  const [expanded, setExpanded] = useState(searchPage)
21
21
  useMemo(() => {
22
- if (expanded !== searchPage) setExpanded(searchPage)
23
- }, [expanded, searchPage])
22
+ if (!searchPage) setExpanded(searchPage)
23
+ }, [searchPage])
24
24
 
25
25
  const visible = expanded || searchPage
26
- const inputRef = useRef<HTMLInputElement>(null)
27
26
 
28
27
  return (
29
28
  <>
@@ -31,7 +30,8 @@ export function ProductFiltersProSearchField(props: ProductFiltersProSearchField
31
30
  <ProductFiltersProSearchInputLazy
32
31
  {...props}
33
32
  formControl={formControl}
34
- inputRef={inputRef}
33
+ inputRef={(element: HTMLInputElement) => element?.focus()}
34
+ // autoFocus
35
35
  buttonProps={{
36
36
  onClick: () => {
37
37
  setExpanded(false)
@@ -45,17 +45,13 @@ export function ProductFiltersProSearchField(props: ProductFiltersProSearchField
45
45
  <Fab
46
46
  onClick={() => {
47
47
  setExpanded(true)
48
- inputRef.current?.focus()
48
+ // inputRef.current?.focus()
49
49
  }}
50
50
  color='inherit'
51
51
  size='large'
52
52
  {...fab}
53
53
  sx={[
54
- {
55
- display: {
56
- xs: visible ? 'none' : 'inline-flex',
57
- },
58
- },
54
+ { display: { xs: visible ? 'none' : 'inline-flex' } },
59
55
  ...(Array.isArray(fab?.sx) ? fab.sx : [fab?.sx]),
60
56
  ]}
61
57
  >
@@ -14,6 +14,7 @@ import { StoreConfigDocument } from '@graphcommerce/magento-store'
14
14
  import { useEventCallback } from '@mui/material'
15
15
  import {
16
16
  productListApplySearchDefaults,
17
+ searchDefaultsToProductListFilters,
17
18
  useProductListApplySearchDefaults,
18
19
  } from '../utils/productListApplySearchDefaults'
19
20
 
@@ -31,10 +32,9 @@ export function useProductList<
31
32
  const { params, shallow } = useRouterFilterParams(props)
32
33
  const variables = useProductListApplySearchDefaults(params)
33
34
  const result = useInContextQuery(ProductListDocument, { variables, skip: !shallow }, props)
34
-
35
35
  const filters = useInContextQuery(
36
36
  ProductFiltersDocument,
37
- { variables: { search: params?.search }, skip: !shallow },
37
+ { variables: searchDefaultsToProductListFilters(variables), skip: !shallow },
38
38
  props,
39
39
  )
40
40
 
@@ -44,8 +44,10 @@ export function useProductList<
44
44
  async (formValues, next) => {
45
45
  if (!storeConfig) return
46
46
 
47
+ const vars = productListApplySearchDefaults(toProductListParams(formValues), storeConfig)
47
48
  await prefetchProductList(
48
- productListApplySearchDefaults(toProductListParams(formValues), storeConfig),
49
+ vars,
50
+ searchDefaultsToProductListFilters(vars),
49
51
  next,
50
52
  result.client,
51
53
  true,
package/index.ts CHANGED
@@ -23,4 +23,4 @@ export {
23
23
 
24
24
  export * from '@graphcommerce/magento-product/components/ProductFiltersPro'
25
25
  export * from './utils/productListApplySearchDefaults'
26
- export * from './components/SearchForm/ProductFiltersProSearchField'
26
+ export * from './components/ProductFiltersPro/ProductFiltersProSearchField'
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graphcommerce/magento-search",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "9.0.0-canary.58",
5
+ "version": "9.0.0-canary.59",
6
6
  "sideEffects": false,
7
7
  "prettier": "@graphcommerce/prettier-config-pwa",
8
8
  "eslintConfig": {
@@ -12,16 +12,16 @@
12
12
  }
13
13
  },
14
14
  "peerDependencies": {
15
- "@graphcommerce/ecommerce-ui": "^9.0.0-canary.58",
16
- "@graphcommerce/eslint-config-pwa": "^9.0.0-canary.58",
17
- "@graphcommerce/graphql": "^9.0.0-canary.58",
18
- "@graphcommerce/image": "^9.0.0-canary.58",
19
- "@graphcommerce/magento-product": "^9.0.0-canary.58",
20
- "@graphcommerce/magento-store": "^9.0.0-canary.58",
21
- "@graphcommerce/next-ui": "^9.0.0-canary.58",
22
- "@graphcommerce/prettier-config-pwa": "^9.0.0-canary.58",
23
- "@graphcommerce/react-hook-form": "^9.0.0-canary.58",
24
- "@graphcommerce/typescript-config-pwa": "^9.0.0-canary.58",
15
+ "@graphcommerce/ecommerce-ui": "^9.0.0-canary.59",
16
+ "@graphcommerce/eslint-config-pwa": "^9.0.0-canary.59",
17
+ "@graphcommerce/graphql": "^9.0.0-canary.59",
18
+ "@graphcommerce/image": "^9.0.0-canary.59",
19
+ "@graphcommerce/magento-product": "^9.0.0-canary.59",
20
+ "@graphcommerce/magento-store": "^9.0.0-canary.59",
21
+ "@graphcommerce/next-ui": "^9.0.0-canary.59",
22
+ "@graphcommerce/prettier-config-pwa": "^9.0.0-canary.59",
23
+ "@graphcommerce/react-hook-form": "^9.0.0-canary.59",
24
+ "@graphcommerce/typescript-config-pwa": "^9.0.0-canary.59",
25
25
  "@lingui/core": "^4.2.1",
26
26
  "@lingui/macro": "^4.2.1",
27
27
  "@lingui/react": "^4.2.1",
@@ -39,3 +39,12 @@ export function productListApplySearchDefaults(
39
39
 
40
40
  return newParams
41
41
  }
42
+
43
+ export function searchDefaultsToProductListFilters(
44
+ variables: ProductListQueryVariables | undefined,
45
+ ): ProductListQueryVariables {
46
+ return {
47
+ ...variables,
48
+ filters: {},
49
+ }
50
+ }