Skip to content

Commit

Permalink
[react-nav-preview](feat): Allowing Nav to be navigable by tabbing (m…
Browse files Browse the repository at this point in the history
  • Loading branch information
mltejera authored Nov 8, 2024
1 parent 27655a9 commit 424835a
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "feat: Exposed 'tabbable' prop on NavDrawer to let consumers disagree with default arrowing opinion.",
"packageName": "@fluentui/react-nav-preview",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,9 @@ export type NavDrawerHeaderSlots = DrawerHeaderSlots;
export type NavDrawerHeaderState = DrawerHeaderState;

// @public
export type NavDrawerProps = ComponentProps<NavDrawerSlots> & DrawerProps & NavProps;
export type NavDrawerProps = ComponentProps<NavDrawerSlots> & DrawerProps & NavProps & {
tabbable?: boolean;
};

// @public
export type NavDrawerSlots = DrawerSlots;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,16 @@ export type NavDrawerSlots = DrawerSlots;
/**
* NavDrawer Props
*/
export type NavDrawerProps = ComponentProps<NavDrawerSlots> & DrawerProps & NavProps;
export type NavDrawerProps = ComponentProps<NavDrawerSlots> &
DrawerProps &
NavProps & {
/**
* The component uses arrow navigation by default.
* Setting this to true enables tab AND arrow navigation.
* @default false
*/
tabbable?: boolean;
};

/**
* State used in rendering NavDrawer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ import type { NavDrawerProps, NavDrawerState } from './NavDrawer.types';
* @param ref - reference to root HTMLDivElement of NavDrawer
*/
export const useNavDrawer_unstable = (props: NavDrawerProps, ref: React.Ref<HTMLDivElement>): NavDrawerState => {
const { tabbable = false } = props;

const focusAttributes = useArrowNavigationGroup({
axis: 'vertical',
circular: true,
tabbable,
});

const navState = useNav_unstable(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ export const Controlled = (props: Partial<NavDrawerProps>) => {
// multiple={isMultiple}
onNavCategoryItemToggle={handleCategoryToggle}
onNavItemSelect={handleItemSelect}
tabbable={true} // enables keyboard tabbing
openCategories={openCategories}
selectedValue={selectedValue}
selectedCategoryValue={selectedCategoryValue}
Expand Down

0 comments on commit 424835a

Please sign in to comment.