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

[Menubar] Base implementation of refactored NavBar #3279

Open
wants to merge 42 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
b16dada
fix: renamed files, components, imports, exports, contexts, and methods
tespin Nov 16, 2024
0f9cf65
refactor: separated UserMenu from the menubar component, wrapped both…
tespin Nov 18, 2024
ab818ad
style: updated header and menubar styles
tespin Nov 18, 2024
246597f
refactor: moved LanguageMenu into left items
tespin Nov 18, 2024
9f3096c
refactor: split new MenubarMenu component into Trigger, List, and Men…
tespin Nov 19, 2024
7c3b896
test: updated snapshots
tespin Nov 19, 2024
b2eb033
refactor: removed menuitem roles from sign up and login, added role=p…
tespin Nov 19, 2024
06e9152
fix: lint fixes
tespin Nov 19, 2024
905ac20
chore: added separators between components within MenubarMenu
tespin Nov 19, 2024
30f2c1b
Merge branch 'develop' into tespin/refactor-navbar-base
tespin Nov 19, 2024
b8a45d5
Fix#3241 Icon Alligment issue in Password Field
Nov 2, 2024
dbc98dd
added some fixes on the eye-svg
Nov 23, 2024
72daf4d
missing dispatch import
raclim Nov 26, 2024
e5e2ec1
wrap actions with dispatch
raclim Nov 27, 2024
f122ec6
update test to add useDispatch
raclim Nov 27, 2024
5c8a912
update dispatch and add selectors
raclim Nov 28, 2024
2177976
create parseFileName util
raclim Nov 28, 2024
0e9a967
update FileNode tests
raclim Nov 28, 2024
fd3e3a6
update FileNode import
raclim Nov 28, 2024
48f9ad8
added donation banner
Stefterv Nov 30, 2024
f84ebd9
2.15.4
raclim Dec 3, 2024
a361329
Revert "Fix Console Errors and Update Hooks in FileNode"
raclim Dec 3, 2024
b63c031
add back in consoleinput changes
raclim Dec 3, 2024
c8118f6
2.15.5
raclim Dec 3, 2024
16644f3
add apple pay id
raclim Dec 4, 2024
9444470
remove static folder
raclim Dec 4, 2024
060b13a
actually delete the static folder
raclim Dec 4, 2024
096edb8
move to public folder
raclim Dec 4, 2024
89a81d8
ensure content type is set correctly in server
raclim Dec 4, 2024
41b10f9
set absolute path
raclim Dec 4, 2024
50077b6
explicitly set root path
raclim Dec 4, 2024
043eb44
remove apple pay setup in server
raclim Dec 5, 2024
71fd59e
2.15.6
raclim Dec 5, 2024
d42872f
Remove Icon from README.md
raclim Dec 6, 2024
4d2ae14
Merge branch 'develop' into tespin/refactor-navbar-base
tespin Dec 13, 2024
c5a2f94
Merge branch 'develop' into tespin/refactor-navbar-base
tespin Jan 8, 2025
e1a4a97
fix: moved usermenu back into menubar to reenable dropdown behavior
tespin Jan 8, 2025
3022bb8
chore: added reference article as comment
tespin Jan 8, 2025
d7e2dc1
fix: removed layout shift on user and example pages caused by height:…
tespin Jan 12, 2025
cca3bd5
refactor: renamed MenubarMenu to MenubarSubmenu for clarity
tespin Jan 12, 2025
d4b7672
fix: renamed MenubarMenu components to MenubarSubmenu
tespin Jan 12, 2025
de201ff
feat: supprt listbox role for language selection menu
tespin Jan 12, 2025
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
21 changes: 17 additions & 4 deletions client/components/Menubar/MenubarItem.jsx
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these changes enhance the Menubar components to support both menu and listbox ARIA roles.

summary of changes:

  • add role override props to MenubarSubmenu, MenubarList and MenubarItem
  • add aria-selected attribute for options in listbox context
  • maintain default menu role for backwards compatibility
  • updated PropTypes to document new role options

overall we're still able to use the Submenu for selection patterns like language choosers will keeping overall Menubar functionality.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ import React, { useContext, useMemo } from 'react';
import ButtonOrLink from '../../common/ButtonOrLink';
import { MenubarContext, ParentMenuContext } from './contexts';

function MenubarItem({ hideIf, className, ...rest }) {
function MenubarItem({
hideIf,
className,
role: customRole,
selected,
...rest
}) {
const parent = useContext(ParentMenuContext);

const { createMenuItemHandlers } = useContext(MenubarContext);
Expand All @@ -17,9 +23,12 @@ function MenubarItem({ hideIf, className, ...rest }) {
return null;
}

const role = customRole || 'menuitem';
const ariaSelected = role === 'option' ? { 'aria-selected': selected } : {};

return (
<li className={className}>
<ButtonOrLink {...rest} {...handlers} role="menuitem" />
<ButtonOrLink {...rest} {...handlers} {...ariaSelected} role={role} />
</li>
);
}
Expand All @@ -32,14 +41,18 @@ MenubarItem.propTypes = {
* Provides a way to deal with optional items.
*/
hideIf: PropTypes.bool,
className: PropTypes.string
className: PropTypes.string,
role: PropTypes.oneOf(['menuitem', 'option']),
selected: PropTypes.bool
};

MenubarItem.defaultProps = {
onClick: null,
value: null,
hideIf: false,
className: 'nav__dropdown-item'
className: 'nav__dropdown-item',
role: 'menuitem',
selected: false
};

export default MenubarItem;
59 changes: 46 additions & 13 deletions client/components/Menubar/MenubarSubmenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ export function useMenuProps(id) {
* MenubarTrigger
* -----------------------------------------------------------------------------------------------*/

function MenubarTrigger({ id, title, ...props }) {
function MenubarTrigger({ id, title, role, hasPopup, ...props }) {
const { isOpen, handlers } = useMenuProps(id);

return (
<button
{...handlers}
{...props}
role="menuitem"
aria-haspopup="menu"
role={role}
aria-haspopup={hasPopup}
aria-expanded={isOpen}
>
<span className="nav__item-header">{title}</span>
Expand All @@ -48,16 +48,23 @@ function MenubarTrigger({ id, title, ...props }) {

MenubarTrigger.propTypes = {
id: PropTypes.string.isRequired,
title: PropTypes.node.isRequired
title: PropTypes.node.isRequired,
role: PropTypes.string,
hasPopup: PropTypes.oneOf(['menu', 'listbox', 'true'])
};

MenubarTrigger.defaultProps = {
role: 'menuitem',
hasPopup: 'menu'
};

/* -------------------------------------------------------------------------------------------------
* MenubarList
* -----------------------------------------------------------------------------------------------*/

function MenubarList({ id, children }) {
function MenubarList({ id, children, role, ...props }) {
return (
<ul className="nav__dropdown" role="menu">
<ul className="nav__dropdown" role={role} {...props}>
<ParentMenuContext.Provider value={id}>
{children}
</ParentMenuContext.Provider>
Expand All @@ -67,36 +74,62 @@ function MenubarList({ id, children }) {

MenubarList.propTypes = {
id: PropTypes.string.isRequired,
children: PropTypes.node
children: PropTypes.node,
role: PropTypes.oneOf(['menu', 'listbox'])
};

MenubarList.defaultProps = {
children: null
children: null,
role: 'menu'
};

/* -------------------------------------------------------------------------------------------------
* MenubarSubmenu
* -----------------------------------------------------------------------------------------------*/

function MenubarSubmenu({ id, title, children }) {
function MenubarSubmenu({
id,
title,
children,
triggerRole: customTriggerRole,
listRole: customListRole,
...props
}) {
const { isOpen } = useMenuProps(id);

const triggerRole = customTriggerRole || 'menuitem';
const listRole = customListRole || 'menu';

const hasPopup = listRole === 'listbox' ? 'listbox' : 'menu';

return (
<li className={classNames('nav__item', isOpen && 'nav__item--open')}>
<MenubarTrigger id={id} title={title} />
<MenubarList id={id}>{children}</MenubarList>
<MenubarTrigger
id={id}
title={title}
role={triggerRole}
hasPopup={hasPopup}
{...props}
/>
<MenubarList id={id} role={listRole}>
{children}
</MenubarList>
</li>
);
}

MenubarSubmenu.propTypes = {
id: PropTypes.string.isRequired,
title: PropTypes.node.isRequired,
children: PropTypes.node
children: PropTypes.node,
triggerRole: PropTypes.string,
listRole: PropTypes.string
};

MenubarSubmenu.defaultProps = {
children: null
children: null,
triggerRole: 'menuitem',
listRole: 'menu'
};

export default MenubarSubmenu;
15 changes: 13 additions & 2 deletions client/modules/IDE/components/Header/Nav.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,21 @@ const LanguageMenu = () => {
}

return (
<MenubarSubmenu id="lang" title={languageKeyToLabel(language)}>
<MenubarSubmenu
id="lang"
title={languageKeyToLabel(language)}
triggerRole="button"
listRole="listbox"
>
{sortBy(availableLanguages).map((key) => (
// eslint-disable-next-line react/jsx-no-bind
<MenubarItem key={key} value={key} onClick={handleLangSelection}>
<MenubarItem
key={key}
value={key}
onClick={handleLangSelection}
role="option"
selected={key === language}
>
{languageKeyToLabel(key)}
</MenubarItem>
))}
Expand Down
Loading