agroptima-design-system 1.2.39-beta.0 → 1.2.39
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/package.json +1 -1
- package/src/atoms/CardsTable/CardsTable.scss +0 -8
- package/src/atoms/CardsTable/CardsTableHeader.tsx +1 -9
- package/src/atoms/Modal/ModalDialog.tsx +3 -3
- package/src/stories/Changelog.mdx +2 -1
- package/src/stories/Modal.stories.tsx +1 -1
- package/tests/CardsTable.spec.tsx +0 -19
- package/tests/Modal.spec.tsx +46 -0
package/package.json
CHANGED
|
@@ -144,14 +144,6 @@
|
|
|
144
144
|
@media only screen and (max-width: breakpoints.$large) {
|
|
145
145
|
.cards-table-head {
|
|
146
146
|
display: none;
|
|
147
|
-
|
|
148
|
-
&:has(.desktop-only) {
|
|
149
|
-
display: table-header-group;
|
|
150
|
-
|
|
151
|
-
.cards-table-row {
|
|
152
|
-
display: table-row;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
147
|
}
|
|
156
148
|
|
|
157
149
|
.cards-table-row {
|
|
@@ -4,7 +4,6 @@ import { Alignment } from './CardsTableCell'
|
|
|
4
4
|
export interface CardsTableHeaderProps extends React.ComponentPropsWithoutRef<'th'> {
|
|
5
5
|
align?: Alignment
|
|
6
6
|
actions?: boolean
|
|
7
|
-
desktopOnly?: boolean
|
|
8
7
|
}
|
|
9
8
|
|
|
10
9
|
export function CardsTableHeader({
|
|
@@ -12,17 +11,10 @@ export function CardsTableHeader({
|
|
|
12
11
|
className,
|
|
13
12
|
align = Alignment.Left,
|
|
14
13
|
actions = false,
|
|
15
|
-
desktopOnly = false,
|
|
16
14
|
...props
|
|
17
15
|
}: CardsTableHeaderProps) {
|
|
18
16
|
return (
|
|
19
|
-
<th
|
|
20
|
-
role="columnheader"
|
|
21
|
-
className={classNames('cards-table-header', {
|
|
22
|
-
'desktop-only': desktopOnly,
|
|
23
|
-
})}
|
|
24
|
-
{...props}
|
|
25
|
-
>
|
|
17
|
+
<th role="columnheader" className="cards-table-header" {...props}>
|
|
26
18
|
<div
|
|
27
19
|
className={classNames(
|
|
28
20
|
'cards-table-inner-cell',
|
|
@@ -29,14 +29,14 @@ export function ModalDialog({
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
useEffect(() => {
|
|
32
|
+
if (!isOpen) return
|
|
33
|
+
|
|
32
34
|
keepScrollbarSpace()
|
|
33
|
-
window.addEventListener('resize', keepScrollbarSpace)
|
|
34
35
|
|
|
35
36
|
return () => {
|
|
36
37
|
removeScrollbarSpace()
|
|
37
|
-
window.removeEventListener('resize', keepScrollbarSpace)
|
|
38
38
|
}
|
|
39
|
-
}, [])
|
|
39
|
+
}, [isOpen])
|
|
40
40
|
|
|
41
41
|
useEffect(() => {
|
|
42
42
|
const dialog = dialogRef.current
|
|
@@ -6,7 +6,8 @@ import { Meta } from "@storybook/addon-docs/blocks";
|
|
|
6
6
|
|
|
7
7
|
## 1.2.39
|
|
8
8
|
|
|
9
|
-
*
|
|
9
|
+
* Fix Modal scroll lock not being cleared when the component stays mounted and `isOpen` toggles to `false`
|
|
10
|
+
* Fix Modal scroll lock width flickering on window resize while open, caused by recalculating the scrollbar width after `overflow: hidden` had already removed it
|
|
10
11
|
|
|
11
12
|
## 1.2.38
|
|
12
13
|
|
|
@@ -37,7 +37,7 @@ const meta = {
|
|
|
37
37
|
' <li>Require a response from the user</li>' +
|
|
38
38
|
' <li>Notify the user of any related information</li>' +
|
|
39
39
|
' <li>Confirm a user decision</li>' +
|
|
40
|
-
" <li>It's opened/closed through `isOpen` prop. If we don't want it to be part of the DOM, we can also add a conditional render on the frontend project.</li>" +
|
|
40
|
+
" <li>It's opened/closed through `isOpen` prop — the component can be left mounted and toggled. If we don't want it to be part of the DOM at all (e.g. to avoid rendering its contents until needed), we can also add a conditional render on the frontend project.</li>" +
|
|
41
41
|
' <li>Natively, focus is set on the first nested focusable element and explicitly indicated by default by the browser</li>' +
|
|
42
42
|
" <li>When nesting a Form inside Modal component, remember to add `type='button'` to all Cancel buttons to not to be considered as submitable</li>" +
|
|
43
43
|
'</ul>',
|
|
@@ -128,23 +128,4 @@ describe('CardsTable', () => {
|
|
|
128
128
|
expect(getAllByRole('row').length).toBeGreaterThan(1)
|
|
129
129
|
expect(getAllByRole('cell').length).toBeGreaterThan(1)
|
|
130
130
|
})
|
|
131
|
-
|
|
132
|
-
it('marks a header as desktop-only', () => {
|
|
133
|
-
const { getByRole } = render(
|
|
134
|
-
<CardsTable>
|
|
135
|
-
<CardsTableHead>
|
|
136
|
-
<CardsTableRow>
|
|
137
|
-
<CardsTableHeader desktopOnly>Game title</CardsTableHeader>
|
|
138
|
-
</CardsTableRow>
|
|
139
|
-
</CardsTableHead>
|
|
140
|
-
<CardsTableBody>
|
|
141
|
-
<CardsTableRow>
|
|
142
|
-
<CardsTableCell>Tekken 8</CardsTableCell>
|
|
143
|
-
</CardsTableRow>
|
|
144
|
-
</CardsTableBody>
|
|
145
|
-
</CardsTable>,
|
|
146
|
-
)
|
|
147
|
-
|
|
148
|
-
expect(getByRole('columnheader').className).toContain('desktop-only')
|
|
149
|
-
})
|
|
150
131
|
})
|
package/tests/Modal.spec.tsx
CHANGED
|
@@ -145,4 +145,50 @@ describe('Modal', () => {
|
|
|
145
145
|
expect(screen.queryAllByRole('option')).toHaveLength(3)
|
|
146
146
|
expect(screen.getByRole('option', { name: 'Item 3' })).toBeInTheDocument()
|
|
147
147
|
})
|
|
148
|
+
|
|
149
|
+
it('clears the scroll lock when isOpen toggles to false while the modal stays mounted', async () => {
|
|
150
|
+
const originalInnerWidth = window.innerWidth
|
|
151
|
+
Object.defineProperty(window, 'innerWidth', {
|
|
152
|
+
configurable: true,
|
|
153
|
+
value: 1024,
|
|
154
|
+
})
|
|
155
|
+
Object.defineProperty(document.documentElement, 'clientWidth', {
|
|
156
|
+
configurable: true,
|
|
157
|
+
value: 1000,
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
const user = userEvent.setup()
|
|
161
|
+
const ToggleableModal = () => {
|
|
162
|
+
const [isOpen, setIsOpen] = React.useState(true)
|
|
163
|
+
|
|
164
|
+
return (
|
|
165
|
+
<Modal
|
|
166
|
+
id="scroll-lock-modal"
|
|
167
|
+
isOpen={isOpen}
|
|
168
|
+
title="Scroll lock modal"
|
|
169
|
+
buttons={[
|
|
170
|
+
{
|
|
171
|
+
label: 'Close',
|
|
172
|
+
onClick: () => setIsOpen(false),
|
|
173
|
+
},
|
|
174
|
+
]}
|
|
175
|
+
>
|
|
176
|
+
content
|
|
177
|
+
</Modal>
|
|
178
|
+
)
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
render(<ToggleableModal />)
|
|
182
|
+
|
|
183
|
+
expect(document.documentElement).toHaveClass('modal-scroll')
|
|
184
|
+
|
|
185
|
+
await user.click(screen.getByRole('button', { name: 'Close' }))
|
|
186
|
+
|
|
187
|
+
expect(document.documentElement).not.toHaveClass('modal-scroll')
|
|
188
|
+
|
|
189
|
+
Object.defineProperty(window, 'innerWidth', {
|
|
190
|
+
configurable: true,
|
|
191
|
+
value: originalInnerWidth,
|
|
192
|
+
})
|
|
193
|
+
})
|
|
148
194
|
})
|