import { CodeSnippet } from '@fluentui/docs-components'; import * as React from 'react'; import { Header } from '@fluentui/react-northstar'; import { Link } from 'react-router-dom'; import DocPage from '../components/DocPage'; import { code, link } from '../utils/helpers'; import ComponentPropsTable from '../components/ComponentDoc/ComponentPropsTable'; export default () => (
Content
Overview

{code('AutoFocusZone')} can be integrated into {code('Popup')} component and is used to grab focus and put it to an inner element when the component mounts. This can be achieved by specifying {code('autoFocus')} prop on the{' '} {code('Popup')}.

If you need both - grabbing the focus and trap the focus in the component - use {code('trapFocus')} prop for{' '} {code('Popup')} to integrate FocusTrapZone.

Usage

In {code('Popup')}, set {code('autoFocus')} to {code('true')} with default settings or set an object with desired values for auto focus zone props.

By default, focus will be set to the first tabbable element in the Popup:

`} />

{code('AutoFocusZone')}'s props which can be applied to {code('autoFocus')} prop ( {link( 'lookup for API on GitHub', 'https://github.com/microsoft/fluentui/blob/master/packages/fluentui/react-bindings/src/FocusZone/AutoFocusZone.types.tsx', )} ):

Override {code('AutoFocusZone')} settings

For example, we want to specify the focusable selector for Popup with auto focus. On Popup mount, focus will go to the element matched to that selector. For that purpose, we can specify {code('firstFocusableSelector')}.

( )`} />

Read more about:

  • Accessibility Behaviors
  • FocusZone
  • FocusTrapZone

{code('AutoFocusZone')} code on{' '} {link( 'GitHub.', 'https://github.com/microsoft/fluentui/blob/master/packages/fluentui/react-bindings/src/FocusZone/AutoFocusZone.tsx', )}

);