Skip to content

Commit

Permalink
fix active state w/ menu (#305)
Browse files Browse the repository at this point in the history
  • Loading branch information
hswolff authored Mar 6, 2020
1 parent ebb5102 commit fd6408b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 9 deletions.
3 changes: 1 addition & 2 deletions packages/menu/src/Menu.story.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ function Controlled() {
setOpen={setOpen}
>
<MenuItem
active
size={select('Size', ['default', 'large'], 'large')}
glyph={<Icon glyph="Laptop" size="xlarge" />}
>
Expand All @@ -60,7 +59,7 @@ function Controlled() {
<MenuItem disabled={boolean('Disabled', true)} size="large">
Disabled Menu Item
</MenuItem>
<MenuItem description="I am a description" size="large">
<MenuItem active description="I am a description" size="large">
Menu Item With Description
</MenuItem>
<MenuItem href="http://mongodb.design" size="large">
Expand Down
7 changes: 0 additions & 7 deletions packages/menu/src/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { isComponentType, keyMap } from '@leafygreen-ui/lib';
import { css, cx } from '@leafygreen-ui/emotion';
import { uiColors } from '@leafygreen-ui/palette';
import { transparentize } from 'polished';
import { useUsingKeyboardContext } from '@leafygreen-ui/leafygreen-provider';

const rootMenuStyle = css`
width: 200px;
Expand Down Expand Up @@ -105,8 +104,6 @@ function Menu({
> | null>(null);
const [uncontrolledOpen, uncontrolledSetOpen] = useState(false);

const { setUsingKeyboard } = useUsingKeyboardContext();

const setOpen =
(typeof controlledOpen === 'boolean' && controlledSetOpen) ||
uncontrolledSetOpen;
Expand All @@ -132,8 +129,6 @@ function Menu({

if (open && hasSetInitialFocus.current === false) {
setFocus(refs[0]);
// This allows the focus state to be shown via the LeafyGreen Provider
setUsingKeyboard(true);
hasSetInitialFocus.current = true;
}
};
Expand Down Expand Up @@ -213,13 +208,11 @@ function Menu({
if (focusedRefIndex !== -1) {
const subMenu = refs[focusedRefIndex];
subMenu.focus();
setUsingKeyboard(true);
}
} else {
if (focusedRefIndex !== -1) {
const subMenuFirstChild = refs[focusedRefIndex + 1];
subMenuFirstChild?.focus();
setUsingKeyboard(true);
}
}
}, [currentSubMenu]);
Expand Down

0 comments on commit fd6408b

Please sign in to comment.