Skip to content

Commit 609f07e

Browse files
authored
Merge pull request #1784 from chanzuckerberg/release-v13.6.0
## [13.6.0](v13.5.0...v13.6.0) (2023-10-13) ### Features * **Menu:** allow href and onClick to co-exist on a menu item ([#1779](#1779)) ([971f189](971f189)) * **Popover:** allow focus upon popover panel open ([#1782](#1782)) ([76ddbc6](76ddbc6)) ### Bug Fixes * **Accordion:** handle multi-line text in headers ([#1783](#1783)) ([0b3c3e6](0b3c3e6)) * **Select:** expose render prop and default value param.s ([#1781](#1781)) ([f21e2b6](f21e2b6))
2 parents 194ea55 + 69d0d52 commit 609f07e

18 files changed

+1280
-778
lines changed

.yarn/releases/yarn-3.6.3.cjs renamed to .yarn/releases/yarn-3.6.4.cjs

+131-131
Large diffs are not rendered by default.

.yarnrc.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ plugins:
66
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
77
spec: "@yarnpkg/plugin-interactive-tools"
88

9-
yarnPath: .yarn/releases/yarn-3.6.3.cjs
9+
yarnPath: .yarn/releases/yarn-3.6.4.cjs

CHANGELOG.md

+14
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5+
## [13.6.0](https://github.com/chanzuckerberg/edu-design-system/compare/v13.5.0...v13.6.0) (2023-10-13)
6+
7+
8+
### Features
9+
10+
* **Menu:** allow href and onClick to co-exist on a menu item ([#1779](https://github.com/chanzuckerberg/edu-design-system/issues/1779)) ([971f189](https://github.com/chanzuckerberg/edu-design-system/commit/971f189aff4a8e08de7a73df4c44332e12dcd6e3))
11+
* **Popover:** allow focus upon popover panel open ([#1782](https://github.com/chanzuckerberg/edu-design-system/issues/1782)) ([76ddbc6](https://github.com/chanzuckerberg/edu-design-system/commit/76ddbc6447658d92219430278ac0eb0ed8d5aa91))
12+
13+
14+
### Bug Fixes
15+
16+
* **Accordion:** handle multi-line text in headers ([#1783](https://github.com/chanzuckerberg/edu-design-system/issues/1783)) ([0b3c3e6](https://github.com/chanzuckerberg/edu-design-system/commit/0b3c3e6f3528c238e3695d55773d9b7636057f99))
17+
* **Select:** expose render prop and default value param.s ([#1781](https://github.com/chanzuckerberg/edu-design-system/issues/1781)) ([f21e2b6](https://github.com/chanzuckerberg/edu-design-system/commit/f21e2b686ab159b498633d8c1cad9f0028988752))
18+
519
## [13.5.0](https://github.com/chanzuckerberg/edu-design-system/compare/v13.4.0...v13.5.0) (2023-10-06)
620

721

package.json

+18-18
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@chanzuckerberg/eds",
3-
"version": "13.5.0",
3+
"version": "13.6.0",
44
"description": "The React-powered design system library for Chan Zuckerberg Initiative education web applications",
55
"author": "CZI <[email protected]>",
66
"homepage": "https://github.com/chanzuckerberg/edu-design-system",
@@ -119,44 +119,44 @@
119119
"@commitlint/cli": "^17.7.2",
120120
"@commitlint/config-conventional": "^17.7.0",
121121
"@geometricpanda/storybook-addon-badges": "^2.0.0",
122-
"@omlet/cli": "^1.0.1-beta.36",
123-
"@rollup/plugin-node-resolve": "^15.2.1",
124-
"@rollup/plugin-typescript": "^11.1.4",
122+
"@omlet/cli": "^1.0.1-beta.37",
123+
"@rollup/plugin-node-resolve": "^15.2.2",
124+
"@rollup/plugin-typescript": "^11.1.5",
125125
"@size-limit/file": "^8.2.6",
126-
"@storybook/addon-a11y": "^7.4.5",
127-
"@storybook/addon-docs": "^7.4.5",
128-
"@storybook/addon-essentials": "^7.4.5",
129-
"@storybook/addon-interactions": "^7.4.5",
130-
"@storybook/addon-links": "^7.4.5",
126+
"@storybook/addon-a11y": "^7.4.6",
127+
"@storybook/addon-docs": "^7.4.6",
128+
"@storybook/addon-essentials": "^7.4.6",
129+
"@storybook/addon-interactions": "^7.4.6",
130+
"@storybook/addon-links": "^7.4.6",
131131
"@storybook/addon-styling": "^1.3.7",
132-
"@storybook/react": "^7.4.5",
133-
"@storybook/react-webpack5": "^7.4.5",
132+
"@storybook/react": "^7.4.6",
133+
"@storybook/react-webpack5": "^7.4.6",
134134
"@storybook/testing-library": "^0.2.0",
135135
"@storybook/testing-react": "^2.0.1",
136136
"@testing-library/jest-dom": "^5.17.0",
137137
"@testing-library/react": "^13.4.0",
138138
"@testing-library/user-event": "^14.5.1",
139139
"@types/jest": "^29.5.5",
140-
"@types/node": "^18.18.0",
141-
"@types/react": "^18.2.23",
140+
"@types/node": "^18.18.3",
141+
"@types/react": "^18.2.25",
142142
"@types/react-beautiful-dnd": "^13.1.5",
143-
"@types/react-dom": "^18.2.8",
143+
"@types/react-dom": "^18.2.10",
144144
"@types/react-portal": "^4.0.4",
145145
"axe-core": "4.8.2",
146146
"chromatic": "^6.24.1",
147147
"codecov": "^3.8.3",
148148
"copyfiles": "^2.4.1",
149149
"eslint": "^8.50.0",
150150
"eslint-config-prettier": "^8.10.0",
151-
"eslint-plugin-jest": "^27.4.0",
151+
"eslint-plugin-jest": "^27.4.2",
152152
"eslint-plugin-prettier": "^4.2.1",
153153
"eslint-plugin-storybook": "^0.6.13",
154154
"eslint-plugin-testing-library": "^5.11.1",
155155
"husky": "^8.0.3",
156156
"identity-obj-proxy": "^3.0.0",
157157
"jest": "^29.7.0",
158158
"jest-environment-jsdom": "^29.7.0",
159-
"jest-preset-stylelint": "^6.2.0",
159+
"jest-preset-stylelint": "^6.3.0",
160160
"lint-staged": "^13.3.0",
161161
"pascal-case": "^3.1.2",
162162
"plop": "^3.1.2",
@@ -174,7 +174,7 @@
174174
"size-limit": "^8.2.6",
175175
"snake-case": "^3.0.4",
176176
"standard-version": "^9.5.0",
177-
"storybook": "^7.4.5",
177+
"storybook": "^7.4.6",
178178
"style-dictionary": "^3.8.0",
179179
"stylelint": "^15.10.3",
180180
"stylelint-config-recommended": "^10.0.1",
@@ -191,5 +191,5 @@
191191
"stylelint --fix"
192192
]
193193
},
194-
"packageManager": "[email protected].3"
194+
"packageManager": "[email protected].4"
195195
}

src/components/Accordion/Accordion.module.css

+11-7
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,11 @@
2525
border: 0;
2626
border-radius: 0;
2727

28-
padding: var(--eds-size-2) var(--eds-size-1);
29-
height: 3.375rem;
28+
padding: var(--eds-size-1-and-half) var(--eds-size-1);
29+
height: unset;
30+
min-height: 3.375rem;
31+
32+
text-align: left;
3033
}
3134

3235
.accordion-button--empty {
@@ -37,22 +40,22 @@
3740
* Small variant.
3841
*/
3942
.accordion-button--sm {
40-
padding: var(--eds-size-1);
41-
height: 2.25rem;
43+
padding: var(--eds-size-half) var(--eds-size-1);
44+
min-height: 2.25rem;
4245
}
4346

4447
/**
4548
* Outline variant.
4649
*/
4750
.accordion-button--outline {
48-
padding: var(--eds-size-2) var(--eds-size-3);
51+
padding: var(--eds-size-1-and-half) var(--eds-size-3);
4952
}
5053

5154
/**
5255
* Small outline variant.
5356
*/
5457
.accordion-button--sm.accordion-button--outline {
55-
padding: var(--eds-size-1) var(--eds-size-2);
58+
padding: var(--eds-size-half) var(--eds-size-2);
5659
}
5760

5861
/**
@@ -73,9 +76,10 @@
7376
/**
7477
* Expand more (chevron) icon indicates open or closed status.
7578
*
76-
* This nonrotated icon points down and represents closed status.
79+
* This non-rotated icon points down and represents closed status.
7780
*/
7881
.accordion-button__icon {
82+
flex: 0 0 content;
7983
transform: rotate(0);
8084
}
8185
/**

src/components/Accordion/Accordion.stories.tsx

+29-5
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,14 @@ import type { StoryObj, Meta } from '@storybook/react';
22
import React from 'react';
33

44
import { Accordion } from './Accordion';
5+
import { chromaticViewports } from '../../util/viewports';
56
import Icon from '../Icon';
67
import NumberIcon from '../NumberIcon';
78
import Text from '../Text';
89

910
export default {
1011
title: 'Components/Accordion',
1112
component: Accordion,
12-
subcomponents: {
13-
'Accordion.Row': Accordion.Row,
14-
'Accordion.Panel': Accordion.Panel,
15-
'Accordion.Button': Accordion.Button,
16-
},
1713
parameters: {
1814
badges: ['1.2'],
1915
},
@@ -305,6 +301,34 @@ export const UsingRenderProp: StoryObj<Args> = {
305301
},
306302
};
307303

304+
/**
305+
* Although headings should provide limited text, we allow for text to span multiple lines, preserving
306+
* the size of the state caret.
307+
*/
308+
export const WithLargeHeader: StoryObj<Args> = {
309+
parameters: {
310+
chromatic: {
311+
viewports: [chromaticViewports.ipadMini],
312+
},
313+
},
314+
args: {
315+
children: (
316+
<Accordion.Row>
317+
<Accordion.Button>
318+
Massa quam egestas massa. Massa quam egestas massa. Massa quam egestas
319+
massa. Massa quam egestas massa. Massa quam egestas massa.
320+
</Accordion.Button>
321+
<Accordion.Panel>
322+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla amet,
323+
massa ultricies iaculis. Quam lacus maecenas nibh malesuada. At
324+
tristique et ullamcorper rhoncus amet pharetra aliquet tortor.
325+
Suscipit dui, nunc sit dui tellus massa laoreet tellus.
326+
</Accordion.Panel>
327+
</Accordion.Row>
328+
),
329+
},
330+
};
331+
308332
export const UsingComplexHeaders: StoryObj<Args> = {
309333
parameters: {
310334
badges: ['1.2', 'implementationExample'],

src/components/Accordion/__snapshots__/Accordion.test.tsx.snap

+49-4
Original file line numberDiff line numberDiff line change
@@ -1732,7 +1732,7 @@ exports[`<Accordion /> UsingComplexHeaders story renders snapshot 1`] = `
17321732
aria-expanded="false"
17331733
class="clickable-style clickable-style--lg clickable-style--icon clickable-style--neutral clickable-style--full-width button button--icon accordion-button"
17341734
data-headlessui-state=""
1735-
id="headlessui-disclosure-button-:r2i:"
1735+
id="headlessui-disclosure-button-:r2k:"
17361736
type="button"
17371737
>
17381738
<h2
@@ -1784,7 +1784,7 @@ exports[`<Accordion /> UsingComplexHeaders story renders snapshot 1`] = `
17841784
aria-expanded="false"
17851785
class="clickable-style clickable-style--lg clickable-style--icon clickable-style--neutral clickable-style--full-width button button--icon accordion-button"
17861786
data-headlessui-state=""
1787-
id="headlessui-disclosure-button-:r2k:"
1787+
id="headlessui-disclosure-button-:r2m:"
17881788
type="button"
17891789
>
17901790
<h2
@@ -1847,7 +1847,7 @@ exports[`<Accordion /> UsingNumberIconInHeaders story renders snapshot 1`] = `
18471847
aria-expanded="false"
18481848
class="clickable-style clickable-style--lg clickable-style--icon clickable-style--neutral clickable-style--full-width button button--icon accordion-button"
18491849
data-headlessui-state=""
1850-
id="headlessui-disclosure-button-:r2m:"
1850+
id="headlessui-disclosure-button-:r2o:"
18511851
type="button"
18521852
>
18531853
<h2
@@ -1896,7 +1896,7 @@ exports[`<Accordion /> UsingNumberIconInHeaders story renders snapshot 1`] = `
18961896
aria-expanded="false"
18971897
class="clickable-style clickable-style--lg clickable-style--icon clickable-style--neutral clickable-style--full-width button button--icon accordion-button"
18981898
data-headlessui-state=""
1899-
id="headlessui-disclosure-button-:r2o:"
1899+
id="headlessui-disclosure-button-:r2q:"
19001900
type="button"
19011901
>
19021902
<h2
@@ -1988,3 +1988,48 @@ exports[`<Accordion /> UsingRenderProp story renders snapshot 1`] = `
19881988
</div>
19891989
</div>
19901990
`;
1991+
1992+
exports[`<Accordion /> WithLargeHeader story renders snapshot 1`] = `
1993+
<div
1994+
style="margin: 0.5rem;"
1995+
>
1996+
<div
1997+
class=""
1998+
>
1999+
<div
2000+
class="accordion-row"
2001+
>
2002+
<button
2003+
aria-expanded="false"
2004+
class="clickable-style clickable-style--lg clickable-style--icon clickable-style--neutral clickable-style--full-width button button--icon accordion-button"
2005+
data-headlessui-state=""
2006+
id="headlessui-disclosure-button-:r2i:"
2007+
type="button"
2008+
>
2009+
<h2
2010+
class="heading heading--size-h2 accordion-button__heading"
2011+
>
2012+
Massa quam egestas massa. Massa quam egestas massa. Massa quam egestas massa. Massa quam egestas massa. Massa quam egestas massa.
2013+
</h2>
2014+
<svg
2015+
class="icon accordion-button__icon"
2016+
fill="currentColor"
2017+
height="1.625rem"
2018+
role="img"
2019+
style="--icon-size: 1.625rem;"
2020+
viewBox="0 0 24 24"
2021+
width="1.625rem"
2022+
xmlns="http://www.w3.org/2000/svg"
2023+
>
2024+
<title>
2025+
show content
2026+
</title>
2027+
<path
2028+
d="M15.88 9.29L12 13.17 8.12 9.29c-.39-.39-1.02-.39-1.41 0-.39.39-.39 1.02 0 1.41l4.59 4.59c.39.39 1.02.39 1.41 0l4.59-4.59c.39-.39.39-1.02 0-1.41-.39-.38-1.03-.39-1.42 0z"
2029+
/>
2030+
</svg>
2031+
</button>
2032+
</div>
2033+
</div>
2034+
</div>
2035+
`;

src/components/Menu/Menu.stories.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ export const Default: StoryObj<MenuProps> = {
5555
>
5656
MDN: Menu
5757
</Menu.Item>
58-
{/* eslint-disable-next-line no-alert */}
59-
<Menu.Item onClick={() => alert('Item clicked')}>
58+
<Menu.Item href="#index" onClick={() => console.log('Item clicked')}>
6059
Trigger Action
6160
</Menu.Item>
6261
<Menu.Item disabled href="https://example.org/" icon="warning">

src/components/Menu/Menu.test.tsx

+24
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ const { Default } = composeStories(stories);
1313
const { Opened, ...staticStories } = stories;
1414

1515
describe('<Menu />', () => {
16+
afterEach(() => {
17+
jest.resetAllMocks();
18+
});
1619
generateSnapshots(staticStories, {
1720
getElement: async () => {
1821
const user = userEvent.setup();
@@ -46,6 +49,27 @@ describe('<Menu />', () => {
4649
expect(menuContainer.getAttribute('aria-activedescendant')).not.toBeNull();
4750
});
4851

52+
it('handles onclick events when there is an href present', async () => {
53+
// create a spy on the `log` method, and avoid calling it by setting the mock implementation to nothing
54+
const consoleSpy = jest.spyOn(console, 'log').mockImplementation();
55+
const user = userEvent.setup();
56+
render(<Default />);
57+
const triggerButton = await screen.findByRole('button');
58+
await act(async () => {
59+
await user.click(triggerButton);
60+
});
61+
62+
await act(async () => {
63+
await user.keyboard('{arrowdown}{arrowdown}{arrowdown}');
64+
});
65+
66+
await act(async () => {
67+
await user.keyboard('{enter}');
68+
});
69+
70+
expect(consoleSpy).toHaveBeenCalledTimes(1);
71+
});
72+
4973
it('should close menu on keyboard escape key', async () => {
5074
const user = userEvent.setup();
5175
render(<Default />);

src/components/Menu/Menu.tsx

+2-4
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export type MenuItemProps = ExtractProps<typeof HeadlessMenu.Item> & {
4242
*/
4343
icon?: IconName;
4444
/**
45-
* Configurable action for the menu item action. If both `href` and `onClick` are used, `onClick` takes precedent.
45+
* Configurable action for the menu item upon click
4646
*/
4747
onClick?: MouseEventHandler<HTMLAnchorElement>;
4848
};
@@ -189,8 +189,6 @@ const MenuItem = ({
189189
onClick,
190190
...other
191191
}: MenuItemProps) => {
192-
// If we have an event handler, avoid navigation by discarding the href
193-
const destinationUrl = !onClick ? href : undefined;
194192
return (
195193
<HeadlessMenu.Item {...other}>
196194
{({ active, disabled }) => {
@@ -209,7 +207,7 @@ const MenuItem = ({
209207
) : (
210208
<a
211209
className={clsx(styles['menu__item'])}
212-
href={destinationUrl}
210+
href={href}
213211
onClick={onClick}
214212
>
215213
{listItemView}

0 commit comments

Comments
 (0)