Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix active state w/ menu #305

Merged
merged 2 commits into from
Mar 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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