Skip to content

Commit

Permalink
fix(NavMenuButton): Add missing changes from previous PR
Browse files Browse the repository at this point in the history
  • Loading branch information
maxime-gendron committed Jan 5, 2021
1 parent bb5d153 commit e49c757
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ export function NavMenuButton({
}, [isOpen]);

useEffect(() => {
setFocusedValue(isOpen ? options[0].value : '');
if (options.length > 0) {
setFocusedValue(isOpen ? options[0].value : '');
}
document.addEventListener('mouseup', handleClickOutside);

return () => document.removeEventListener('mouseup', handleClickOutside);
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/nav-menu/nav-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export const NavMenu = forwardRef(({
innerRef={option.ref}
$device={device}
to={option.href}
onClick={() => onChange && onChange(option)}
onClick={() => onChange?.(option)}
onKeyDown={(event) => handleKeyDown(event, option)}
>
{option.label || option.value}
Expand Down

0 comments on commit e49c757

Please sign in to comment.