Private
Public Access
1
0
Files
power-apps-codeapps-blog-part2/node_modules/@fluentui/react-tabster/lib/hooks/useRestoreFocus.js

28 lines
911 B
JavaScript

'use client';
import { getRestorer, getTabsterAttribute, RestorerTypes } from 'tabster';
import { useTabster } from './useTabster';
/**
* Focus will be restored to the most recent target element when it is lost from a source
* @returns Attribute to apply to the target element where focus is restored
*/ export function useRestoreFocusTarget() {
// Initializes the restorer API
useTabster(getRestorer);
return getTabsterAttribute({
restorer: {
type: RestorerTypes.Target
}
});
}
/**
* Focus will be restored to the most recent target element when it is lost from a source
* @returns Attribute to apply to the element that might lose focus
*/ export function useRestoreFocusSource() {
// Initializes the restorer API
useTabster(getRestorer);
return getTabsterAttribute({
restorer: {
type: RestorerTypes.Source
}
});
}