Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "feat: Bump keyborg to 2.0.0 and tabster to 4.0.1",
"packageName": "@fluentui/react-tabster",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ export const useFocusFinders: () => {
findAllFocusable: (container: HTMLElement, acceptCondition?: ((el: HTMLElement) => boolean) | undefined) => HTMLElement[];
findFirstFocusable: (container: HTMLElement) => HTMLElement | null | undefined;
findLastFocusable: (container: HTMLElement) => HTMLElement | null | undefined;
findNextFocusable: (currentElement: HTMLElement, options?: Pick<Types.FindNextProps, 'container'>) => HTMLElement | null | undefined;
findPrevFocusable: (currentElement: HTMLElement, options?: Pick<Types.FindNextProps, 'container'>) => HTMLElement | null | undefined;
findNextFocusable: (currentElement: HTMLElement, options?: Pick<Partial<Types.FindNextProps>, 'container'>) => HTMLElement | null | undefined;
findPrevFocusable: (currentElement: HTMLElement, options?: Pick<Partial<Types.FindNextProps>, 'container'>) => HTMLElement | null | undefined;
};

// @public (undocumented)
Expand Down
4 changes: 2 additions & 2 deletions packages/react-components/react-tabster/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
"@fluentui/react-shared-contexts": "^9.2.0",
"@fluentui/react-theme": "^9.1.5",
"@fluentui/react-utilities": "^9.5.1",
"keyborg": "^1.2.1",
"tabster": "^3.0.6",
"keyborg": "^2.0.0",
"tabster": "^4.1.0",
"tslib": "^2.1.0"
},
"peerDependencies": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import * as React from 'react';
import { Types as TabsterTypes } from 'tabster';
import { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';
import { useTabster } from './useTabster';

/**
* Returns a set of helper functions that will traverse focusable elements in the context of a root DOM element
*/
export const useFocusFinders = () => {
const tabster = useTabster();
const { targetDocument } = useFluent();

// Narrow props for now and let need dictate additional props in the future
const findAllFocusable = React.useCallback(
Expand All @@ -25,15 +27,29 @@ export const useFocusFinders = () => {
]);

const findNextFocusable = React.useCallback(
(currentElement: HTMLElement, options: Pick<TabsterTypes.FindNextProps, 'container'> = {}) =>
tabster?.focusable.findNext({ currentElement, ...options }),
[tabster],
(currentElement: HTMLElement, options: Pick<Partial<TabsterTypes.FindNextProps>, 'container'> = {}) => {
if (!tabster || !targetDocument) {
return null;
}

const { container = targetDocument.body } = options;

return tabster.focusable.findNext({ currentElement, container });
},
[tabster, targetDocument],
);

const findPrevFocusable = React.useCallback(
(currentElement: HTMLElement, options: Pick<TabsterTypes.FindNextProps, 'container'> = {}) =>
tabster?.focusable.findPrev({ currentElement, ...options }),
[tabster],
(currentElement: HTMLElement, options: Pick<Partial<TabsterTypes.FindNextProps>, 'container'> = {}) => {
if (!tabster || !targetDocument) {
return null;
}

const { container = targetDocument.body } = options;

return tabster.focusable.findPrev({ currentElement, container });
},
[tabster, targetDocument],
);

return {
Expand Down
18 changes: 9 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17175,10 +17175,10 @@ [email protected]:
ua-parser-js "^0.7.30"
yargs "^16.1.1"

keyborg@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/keyborg/-/keyborg-1.2.1.tgz#0503719c9b2791d8e4f1a00f7eae7e29327416fa"
integrity sha512-PXjcJb7d4ecncFnJgq1TzLBx38+LbTPDpbwNCXebMzp3xaZeG//7ydWpISouBVyjRtJFuIvpIryme4U2dYGUEg==
keyborg@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/keyborg/-/keyborg-2.0.0.tgz#937e0346bb4e438c0cf26ca6989c56820b4754f6"
integrity sha512-RWY8nWrzRkwTQLaKyDtbTu5SOb5L4B20UzAsBHlQDFZqVY/+Mid0bQ7MVTC8vbOTrWY2xkkzj8gZF9Ua7re4xA==

keygrip@~1.1.0:
version "1.1.0"
Expand Down Expand Up @@ -24119,12 +24119,12 @@ table@^6.0.4, table@^6.0.7:
string-width "^4.2.3"
strip-ansi "^6.0.1"

tabster@^3.0.6:
version "3.0.6"
resolved "https://registry.yarnpkg.com/tabster/-/tabster-3.0.6.tgz#8aa00199e2fadb8de3af8d2f5e1b68d531022fda"
integrity sha512-KrzAMDfnYZWqGu/pPXzsBPEA5l2tBPi8z8newbBCPktHnjdsTB534xQQ+3eKItologlNCJg8ijScajdyWjGAYg==
tabster@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/tabster/-/tabster-4.1.0.tgz#4639d8f27be0a3789912a5594e44813529a9adc8"
integrity sha512-LjnQeCPYvNyJY4tab2Fthasni6alQt1OCctBNIRYjl0b+6CkL0Y79EnX8m4SJ0iEA/DaC1srWRvV8dnKhIiyuw==
dependencies:
keyborg "^1.2.1"
keyborg "^2.0.0"
tslib "^2.3.1"

[email protected]:
Expand Down