@sproutsocial/seeds-react-menu 1.11.9 → 1.12.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sproutsocial/seeds-react-menu",
3
- "version": "1.11.9",
3
+ "version": "1.12.0",
4
4
  "description": "Seeds React Menu",
5
5
  "author": "Sprout Social, Inc.",
6
6
  "license": "MIT",
@@ -26,7 +26,7 @@ import { mapMenuItems } from "../hooks/useMenuChildren";
26
26
  */
27
27
 
28
28
  const MenuGroup = <I extends TypeMenuItemProps = TypeMenuItemProps>({
29
- titleAs = "h3",
29
+ titleAs = "div",
30
30
  children: childrenProp,
31
31
  title,
32
32
  color,
@@ -68,7 +68,7 @@ const MenuGroup = <I extends TypeMenuItemProps = TypeMenuItemProps>({
68
68
  {...rest}
69
69
  >
70
70
  {title && (
71
- <StyledTitle role="heading" as={titleAs} id={titleId}>
71
+ <StyledTitle as={titleAs} id={titleId}>
72
72
  {title}
73
73
  </StyledTitle>
74
74
  )}
@@ -199,12 +199,12 @@ describe("MenuGroup", () => {
199
199
  </SingleSelectMenu>
200
200
  );
201
201
 
202
- // Find associated label for the group. (Menu Group uses aria-labelledby to point to heading element)
202
+ // The group is labelled via aria-labelledby pointing to the title div.
203
+ // The title must not carry role="heading" since heading is not an allowed
204
+ // descendant of listbox/menu (axe: aria-allowed-attr).
203
205
  const menuGroup = screen.getByRole("group", { name: menuTitle });
204
206
  expect(menuGroup).toBeInTheDocument();
205
- expect(
206
- screen.queryByRole("heading", { name: menuTitle })
207
- ).toBeInTheDocument();
207
+ expect(screen.queryByRole("heading")).not.toBeInTheDocument();
208
208
  });
209
209
 
210
210
  it("does not place role=group on an <li> (axe aria-allowed-role)", () => {
@@ -26,6 +26,7 @@ export const MenuSearchInput = ({
26
26
  getIsItemVisible,
27
27
  inputProps,
28
28
  onChange,
29
+ "aria-label": ariaLabel,
29
30
  ...restInputProps
30
31
  }: TypeMenuSearchInputProps) => {
31
32
  const {
@@ -69,8 +70,9 @@ export const MenuSearchInput = ({
69
70
  // apply onKeyDown logic for downshift keyboard accessibility support
70
71
  onKeyDown={handleKeyDown}
71
72
  autoComplete={false}
72
- aria-autocomplete="list"
73
+ ariaLabel={ariaLabel}
73
74
  inputProps={{
75
+ ["aria-autocomplete"]: "list",
74
76
  ["aria-activedescendant"]: toggleButtonProps["aria-activedescendant"],
75
77
  ["aria-controls"]: toggleButtonProps["aria-controls"],
76
78
  ...inputProps,
@@ -275,6 +275,66 @@ export const SingleSelectMenuWithCustomEmpty: Story = {
275
275
  },
276
276
  };
277
277
 
278
+ const russianBooks = TEST_BOOKS.filter(({ author }) =>
279
+ [
280
+ "Leo Tolstoy",
281
+ "Fyodor Dostoyevsy",
282
+ "Fyodor Dostoevsky",
283
+ "Lev Tolstoy",
284
+ ].includes(author)
285
+ );
286
+ const worldBooks = TEST_BOOKS.filter(
287
+ ({ author }) =>
288
+ ![
289
+ "Leo Tolstoy",
290
+ "Fyodor Dostoyevsy",
291
+ "Fyodor Dostoevsky",
292
+ "Lev Tolstoy",
293
+ ].includes(author)
294
+ );
295
+
296
+ export const SingleSelectMenuWithSearchAndGroups: Story = {
297
+ name: "Single Select Menu with Search and Groups",
298
+ render: ({ inputType, ...args }) => {
299
+ return (
300
+ <SingleSelectMenu
301
+ itemToString={(item) => {
302
+ if (!item) return "";
303
+ return TEST_BOOKS.find(({ id }) => id === item.id)?.title ?? "";
304
+ }}
305
+ menuToggleElement={<StorybookMenuToggleButton />}
306
+ onStateChange={(changes) => action("onStateChange")(changes)}
307
+ {...(args as object)}
308
+ >
309
+ <MenuHeader title="Select Book">
310
+ <MenuSearchInput
311
+ id="single-select-search-groups"
312
+ name="search"
313
+ type="search"
314
+ aria-label="Search Books"
315
+ />
316
+ </MenuHeader>
317
+ <MenuContent>
318
+ <MenuGroup id="russian-lit" title="Russian Literature">
319
+ {russianBooks.map(({ id, title }) => (
320
+ <MenuItem key={id} id={id} inputType={inputType}>
321
+ {title}
322
+ </MenuItem>
323
+ ))}
324
+ </MenuGroup>
325
+ <MenuGroup id="world-lit" title="World Literature">
326
+ {worldBooks.map(({ id, title }) => (
327
+ <MenuItem key={id} id={id} inputType={inputType}>
328
+ {title}
329
+ </MenuItem>
330
+ ))}
331
+ </MenuGroup>
332
+ </MenuContent>
333
+ </SingleSelectMenu>
334
+ );
335
+ },
336
+ };
337
+
278
338
  export const SingleSelectMenuSmallSize: Story = {
279
339
  name: "Small Size",
280
340
  render: ({ inputType, ...args }) => {