@graphcommerce/next-ui 11.0.0-canary.54 → 11.0.0-canary.56
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,13 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 11.0.0-canary.56
|
|
4
|
+
|
|
5
|
+
## 11.0.0-canary.55
|
|
6
|
+
|
|
7
|
+
### Patch Changes
|
|
8
|
+
|
|
9
|
+
- [#2714](https://github.com/graphcommerce-org/graphcommerce/pull/2714) [`bdbf083`](https://github.com/graphcommerce-org/graphcommerce/commit/bdbf0831891f1074412bf25e8d13e9f1b176538a) - `NavigationOverlay` focuses its close button without a scroll, so the backdrop fades in when the menu opens. A scrolling `focus()` put the overlay in its open position before `OverlayBase` started the animation. ([@bramvanderholst](https://github.com/bramvanderholst))
|
|
10
|
+
|
|
3
11
|
## 11.0.0-canary.54
|
|
4
12
|
|
|
5
13
|
## 11.0.0-canary.53
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// @vitest-environment happy-dom
|
|
2
|
+
|
|
3
|
+
import { createTheme, ThemeProvider } from '@mui/material'
|
|
4
|
+
import { motionValue } from 'framer-motion'
|
|
5
|
+
import type React from 'react'
|
|
6
|
+
import { act } from 'react'
|
|
7
|
+
import { createRoot } from 'react-dom/client'
|
|
8
|
+
import { afterAll, beforeAll, expect, it, vi } from 'vitest'
|
|
9
|
+
import type { NavigationPath } from '../hooks/useNavigation'
|
|
10
|
+
import { NavigationContext } from '../hooks/useNavigation'
|
|
11
|
+
import { NavigationOverlay } from './NavigationOverlay'
|
|
12
|
+
|
|
13
|
+
vi.mock('@lingui/core/macro', () => ({
|
|
14
|
+
t: (strings: TemplateStringsArray) => strings[0],
|
|
15
|
+
}))
|
|
16
|
+
|
|
17
|
+
vi.mock('../../Overlay/components/OverlaySsr', () => ({
|
|
18
|
+
OverlaySsr: (props: { children: React.ReactNode }) => props.children,
|
|
19
|
+
}))
|
|
20
|
+
|
|
21
|
+
vi.mock('../../Layout/components/LayoutHeaderContent', () => ({
|
|
22
|
+
LayoutHeaderContent: (props: { right: React.ReactNode }) => props.right,
|
|
23
|
+
}))
|
|
24
|
+
|
|
25
|
+
vi.mock('./NavigationList', () => ({ NavigationList: () => null }))
|
|
26
|
+
|
|
27
|
+
const theme = Object.assign(createTheme({ cssVariables: true }), {
|
|
28
|
+
appShell: { headerHeightSm: '46px', appBarHeightMd: '80px' },
|
|
29
|
+
page: { horizontal: '20px' },
|
|
30
|
+
spacings: { md: '20px' },
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
beforeAll(() => {
|
|
34
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
afterAll(() => {
|
|
38
|
+
Reflect.deleteProperty(globalThis, 'IS_REACT_ACT_ENVIRONMENT')
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it('focuses the close button without a scroll of the closed overlay', () => {
|
|
42
|
+
const focus = vi.spyOn(HTMLElement.prototype, 'focus')
|
|
43
|
+
const selection = motionValue<NavigationPath | false>(false)
|
|
44
|
+
const container = document.createElement('div')
|
|
45
|
+
document.body.appendChild(container)
|
|
46
|
+
const root = createRoot(container)
|
|
47
|
+
|
|
48
|
+
act(() =>
|
|
49
|
+
root.render(
|
|
50
|
+
<ThemeProvider theme={theme}>
|
|
51
|
+
<NavigationContext.Provider
|
|
52
|
+
value={{
|
|
53
|
+
selection,
|
|
54
|
+
items: [],
|
|
55
|
+
hideRootOnNavigate: true,
|
|
56
|
+
animating: motionValue(false),
|
|
57
|
+
closing: motionValue(false),
|
|
58
|
+
serverRenderDepth: 2,
|
|
59
|
+
animationDuration: 0.225,
|
|
60
|
+
}}
|
|
61
|
+
>
|
|
62
|
+
<NavigationOverlay variantSm='left' variantMd='left' mouseEvent='click' />
|
|
63
|
+
</NavigationContext.Provider>
|
|
64
|
+
</ThemeProvider>,
|
|
65
|
+
),
|
|
66
|
+
)
|
|
67
|
+
act(() => selection.set([]))
|
|
68
|
+
|
|
69
|
+
const closeButton = container.querySelector('[aria-label="Close"]')
|
|
70
|
+
const [options] = focus.mock.calls.at(-1) ?? []
|
|
71
|
+
const focused = document.activeElement
|
|
72
|
+
|
|
73
|
+
act(() => root.unmount())
|
|
74
|
+
container.remove()
|
|
75
|
+
focus.mockRestore()
|
|
76
|
+
|
|
77
|
+
expect(focused).toBe(closeButton)
|
|
78
|
+
expect(options).toEqual({ preventScroll: true })
|
|
79
|
+
})
|
|
@@ -87,7 +87,8 @@ export const NavigationOverlay = React.memo((props: NavigationOverlayProps) => {
|
|
|
87
87
|
animating.set(true)
|
|
88
88
|
|
|
89
89
|
if (activeAndNotClosing) {
|
|
90
|
-
|
|
90
|
+
// A scrolling focus() puts the overlay in its open position before OverlayBase animates it
|
|
91
|
+
a11yFocusRef.current?.focus({ preventScroll: true })
|
|
91
92
|
}
|
|
92
93
|
}, [activeAndNotClosing, animating])
|
|
93
94
|
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphcommerce/next-ui",
|
|
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.56",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
|
@@ -43,13 +43,13 @@
|
|
|
43
43
|
"@emotion/react": "^11.14.0",
|
|
44
44
|
"@emotion/server": "^11.11.0",
|
|
45
45
|
"@emotion/styled": "^11.14.1",
|
|
46
|
-
"@graphcommerce/eslint-config-pwa": "^11.0.0-canary.
|
|
47
|
-
"@graphcommerce/framer-next-pages": "^11.0.0-canary.
|
|
48
|
-
"@graphcommerce/framer-scroller": "^11.0.0-canary.
|
|
49
|
-
"@graphcommerce/framer-utils": "^11.0.0-canary.
|
|
50
|
-
"@graphcommerce/image": "^11.0.0-canary.
|
|
51
|
-
"@graphcommerce/prettier-config-pwa": "^11.0.0-canary.
|
|
52
|
-
"@graphcommerce/typescript-config-pwa": "^11.0.0-canary.
|
|
46
|
+
"@graphcommerce/eslint-config-pwa": "^11.0.0-canary.56",
|
|
47
|
+
"@graphcommerce/framer-next-pages": "^11.0.0-canary.56",
|
|
48
|
+
"@graphcommerce/framer-scroller": "^11.0.0-canary.56",
|
|
49
|
+
"@graphcommerce/framer-utils": "^11.0.0-canary.56",
|
|
50
|
+
"@graphcommerce/image": "^11.0.0-canary.56",
|
|
51
|
+
"@graphcommerce/prettier-config-pwa": "^11.0.0-canary.56",
|
|
52
|
+
"@graphcommerce/typescript-config-pwa": "^11.0.0-canary.56",
|
|
53
53
|
"@lingui/core": "^5",
|
|
54
54
|
"@lingui/macro": "^5",
|
|
55
55
|
"@lingui/react": "^5",
|