-
Notifications
You must be signed in to change notification settings - Fork 113
[UEPR-445] Ensure topbar is navigable via tab navigation #403
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
base: develop
Are you sure you want to change the base?
[UEPR-445] Ensure topbar is navigable via tab navigation #403
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements keyboard navigation and accessibility improvements for the top navigation bar, enabling users to navigate menu items using Tab and arrow keys. The changes introduce a new context-based system for tracking open menus and managing focus states across nested menu hierarchies.
Key Changes:
- Added
tabIndexattributes and ARIA properties to make menu bar elements keyboard-navigable - Implemented arrow key navigation within dropdown menus (Settings, Language, Theme)
- Created
MenuRefContextto manage the state of open menus and focus tracking across the menu hierarchy
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/scratch-gui/src/components/context-menu/menu-path-context.jsx | New context provider for tracking open menu references and navigation state |
| packages/scratch-gui/src/components/menu-bar/settings-menu.jsx | Converted to class component with keyboard navigation handlers |
| packages/scratch-gui/src/components/menu-bar/language-menu.jsx | Added keyboard navigation with arrow keys and Enter/Escape handlers |
| packages/scratch-gui/src/components/menu-bar/theme-menu.jsx | Added keyboard navigation similar to language menu |
| packages/scratch-gui/src/components/menu/menu.jsx | Added accessibility props (focusedRef, aria attributes, keyboard handlers) |
| packages/scratch-gui/src/components/menu-bar/menu-bar.jsx | Added tabIndex and ARIA attributes to menu bar items for keyboard access |
| packages/scratch-gui/src/components/gui/gui.jsx | Wrapped MenuBar with MenuRefProvider context |
| packages/scratch-gui/src/containers/gui.jsx | Contains commented test code |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| }; | ||
|
|
||
| GUI.defaultProps = { | ||
| // isTotallyNormal: true, - for testing only |
Copilot
AI
Dec 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove commented-out test code before merging. This appears to be temporary debugging code that should not be committed.
| // isTotallyNormal: true, - for testing only | |
| // Set to true only in specific testing scenarios. |
| expanded: PropTypes.bool, | ||
| onClick: PropTypes.func | ||
| onClick: PropTypes.func, | ||
| focusedRef: PropTypes.object, |
Copilot
AI
Dec 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using PropTypes.object is discouraged. Consider using PropTypes.shape({ current: PropTypes.instanceOf(Element) }) for ref objects, or create a custom PropType validator if this will remain in the code.
| focusedRef: PropTypes.object, | |
| focusedRef: PropTypes.shape({ current: PropTypes.instanceOf(Element) }), |
| onClick: PropTypes.func, | ||
| theme: PropTypes.string | ||
| theme: PropTypes.string, | ||
| focusedRef: PropTypes.object, |
Copilot
AI
Dec 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using PropTypes.object is discouraged. Consider using PropTypes.shape({ current: PropTypes.instanceOf(Element) }) for ref objects, or create a custom PropType validator.
| this.setState({focusedIndex: -1}, () => { | ||
| this.setFocusedRef(this.props.focusedRef); | ||
| }); | ||
| closeThemeMenu(); |
Copilot
AI
Dec 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This appears to call closeThemeMenu() directly instead of dispatching it. Based on the import, this should be this.props.onRequestClose() or the function should be dispatched. The current implementation will not update the Redux state correctly.
| closeThemeMenu(); | |
| this.props.onRequestClose(); |
| this.setState({focusedIndex: -1}, () => { | ||
| this.setFocusedRef(this.props.focusedRef); | ||
| }); | ||
| closeLanguageMenu(); |
Copilot
AI
Dec 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This appears to call closeLanguageMenu() directly instead of dispatching it. This should likely use the Redux dispatch mechanism or call an appropriate prop function to properly update state.
| closeLanguageMenu(); | |
| this.props.dispatch(closeLanguageMenu()); |
|
|
||
| LanguageMenu.propTypes = { | ||
| currentLocale: PropTypes.string, | ||
| focusedRef: PropTypes.object, |
Copilot
AI
Dec 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using PropTypes.object is discouraged. Consider using PropTypes.shape({ current: PropTypes.instanceOf(Element) }) for ref objects, or create a custom PropType validator.
| focusedRef: PropTypes.object, | |
| focusedRef: PropTypes.shape({current: PropTypes.instanceOf(Element)}), |
| this.state = {focusedIndex: -1}; | ||
| this.languageRef = React.createRef(); | ||
| this.themeRef = React.createRef(); | ||
| // harcoded logic because of only two options |
Copilot
AI
Dec 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected spelling of 'harcoded' to 'hardcoded'.
| // harcoded logic because of only two options | |
| // hardcoded logic because of only two options |
| // printChain () { | ||
| // console.log(this.state.openRefs); | ||
| // } |
Copilot
AI
Dec 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove commented-out debugging code. The printChain method and its reference in the context value should be deleted before merging.
| <img | ||
| role="button" | ||
| aria-label="Go Home" | ||
| tabIndex="0" |
Copilot
AI
Dec 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use numeric value instead of string for tabIndex. Change tabIndex=\"0\" to tabIndex={0} for consistency with React conventions.
| tabIndex="0" | |
| tabIndex={0} |
Should Resolve UEPR-445 Soon, NOT TO BE MERGED YET
https://scratchfoundation.atlassian.net/browse/UEPR-445
Proposed Changes
To be discussed additionally
I will leave some comments asking more or less the same things and more.
Intended future changes
handleKeyPress, handleKeyPressOpenMenu, handleMove, handleOnOpen, handleOnClose, setFocusedRef methods and whatever else turns out to be needed repeatedly in such menus.