Skip to content

Commit

Permalink
Merge pull request #3045 from Autodesk/development
Browse files Browse the repository at this point in the history
Release: September 14, 2023
  • Loading branch information
wmui51 authored Sep 15, 2023
2 parents b646d96 + b812557 commit 2ea5c74
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion deprecated/side-nav/src/__stories__/SideNavModule.story.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { ArgsTable, Primary, Stories } from "@storybook/addon-docs";
import { Graph24 } from "@weave-designweave-design/icons";
import { Graph24 } from "@weave-design/icons";

import SideNav from "../index";
import Readme from "../../README.md";
Expand Down
7 changes: 7 additions & 0 deletions packages/menu/src/Menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const Menu = (props) => {
children,
defaultSelected,
divider,
highlighted,
menuRef,
multiple,
onChange = () => {},
Expand All @@ -27,6 +28,7 @@ const Menu = (props) => {
{...otherProps}
defaultSelected={defaultSelected}
hasFocus={hasFocus}
highlighted={highlighted}
menuRef={menuRef}
multiple={multiple}
onBlur={handleBlur}
Expand Down Expand Up @@ -102,6 +104,11 @@ Menu.propTypes = {
* Shows a divider at the bottom of the menu
*/
divider: PropTypes.bool,
/**
* Semi-controlled way of having Options highlighted
* Takes the index of the option you want highlighted
*/
highlighted: PropTypes.number,
/**
* A callback ref that gets passed to the HTML
* element with `role="listbox"`
Expand Down
9 changes: 9 additions & 0 deletions packages/menu/src/MenuGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const MenuGroup = (props) => {
const {
children,
defaultSelected,
highlighted,
menuRef,
multiple,
onChange,
Expand All @@ -21,6 +22,7 @@ const MenuGroup = (props) => {
<MenuBehavior
{...otherProps}
defaultSelected={defaultSelected}
highlighted={highlighted}
menuRef={menuRef}
multiple={multiple}
onChange={onChange}
Expand Down Expand Up @@ -84,6 +86,13 @@ MenuGroup.propTypes = {
*/
// eslint-disable-next-line react/forbid-prop-types
defaultSelected: PropTypes.arrayOf(PropTypes.any),
/**
* Semi-controlled way of having Options highlighted
* Takes the index of the option you want highlighted
* This will take precedent over the Menu prop of the
* same name
*/
highlighted: PropTypes.number,
/**
* A callback ref that gets passed to the HTML
* element with `role="listbox"`
Expand Down
7 changes: 7 additions & 0 deletions packages/menu/src/behaviors/MenuBehavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,12 @@ const MenuBehavior = (props) => {
}
}, [props.selected]);

useEffect(() => {
if (props.highlighted >= 0) {
setHighlightIndexHook(props.highlighted + 1);
}
}, [props.highlighted]);

return props.children({
getActiveOption: getActiveOptionMethod,
getHighlightIndex: getHighlightIndexMethod,
Expand Down Expand Up @@ -306,6 +312,7 @@ MenuBehavior.propTypes = {
handleFocus: PropTypes.func,
handleKeyDown: PropTypes.func,
handleMouseMove: PropTypes.func,
highlighted: PropTypes.func,
menuRef: PropTypes.func,
multiple: PropTypes.bool,
onBlur: PropTypes.func,
Expand Down
3 changes: 3 additions & 0 deletions packages/menu/src/presenters/MenuGroupPresenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const MenuGroupPresenter = (props) => {
getHighlightIndex,
getOptionsInfo,
getPreviousEvent,
highlighted,
multiple,
onBlur: handleBlur,
onFocus: handleFocus,
Expand All @@ -44,6 +45,7 @@ const MenuGroupPresenter = (props) => {
handleFocus,
handleKeyDown,
handleMouseMove,
highlighted,
multiple,
selected,
setActiveOption,
Expand Down Expand Up @@ -180,6 +182,7 @@ MenuGroupPresenter.propTypes = {
getHighlightIndex: PropTypes.func,
getOptionsInfo: PropTypes.func,
getPreviousEvent: PropTypes.func,
highlighted: PropTypes.number,
menuRef: PropTypes.func,
multiple: PropTypes.bool,
onBlur: PropTypes.func,
Expand Down
1 change: 1 addition & 0 deletions packages/menu/src/presenters/MenuPresenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const MenuPresenter = (props) => {
delete payload.handleFocus;
delete payload.handleKeyDown;
delete payload.handleMouseMove;
delete payload.highlighted;
delete payload.setActiveOption;
delete payload.setHighlightIndex;
delete payload.setOptionsInfo;
Expand Down

0 comments on commit 2ea5c74

Please sign in to comment.