-
Notifications
You must be signed in to change notification settings - Fork 36
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
feat: react-gamepad-navigation implementation #286
base: main
Are you sure you want to change the base?
Conversation
requesting review from @tudorpopams |
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.
Nice work @hectorjjb! I added a few comments after my initial review, here's a quick summary:
- Avoid using TS
enums
; it's better to use type union or a map with values if you prefer. - Keep type imports consistent by using
import type {}
where needed. - Make sure side effects like adding/removing listeners happen in useEffect.
change/@fluentui-contrib-react-gamepad-navigation-3f106efd-9c1e-4b90-a4a2-817c0bb10c61.json
Outdated
Show resolved
Hide resolved
packages/react-gamepad-navigation/src/hooks/useGamepadNavigationGroup.ts
Outdated
Show resolved
Hide resolved
"options": { | ||
"packageRoot": "dist\\{projectRoot}" | ||
} | ||
"publish": { |
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.
why do we need this?
unstable_hasDefault, | ||
}); | ||
const groupperAttr = useFocusableGroup({ tabBehavior, ignoreDefaultKeydown }); | ||
const gamepadNavDOMAttributes = useMergedTabsterAttributes_unstable( |
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.
@ling1726 @mshoho This hook marked as "internal" https://github.com/microsoft/fluentui/blob/master/packages/react-components/react-tabster/src/hooks/useMergeTabsterAttributes.ts#L8, is okay to use in the extension/cosumer package?
packages/react-gamepad-navigation/src/hooks/useGamepadNavigationGroup.ts
Outdated
Show resolved
Hide resolved
// eslint-disable-next-line @typescript-eslint/no-namespace | ||
namespace React { | ||
interface KeyboardEvent { | ||
readonly [syntheticKey]?: boolean; |
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.
Not sure it's a good practice to change/augment external types
…onGroup.ts Co-authored-by: Dmytro Kirpa <[email protected]>
…onGroup.ts Co-authored-by: Dmytro Kirpa <[email protected]>
Enabling gamepad navigation by using Gamepad Web API and useArrowNavigationGroup under the hood.
Dpad and left stick events are translated to MoverMoveFocusEvent (Arrow navigation)
and A & B buttons are translated into Enter & Escape GroupperMoveFocusEvent respectively.