Skip to content
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

Dropdown: add focusOnMount prop to pass onto Popover component #12855

Merged
merged 1 commit into from
Jan 23, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

- Resolves a conflict where two instance of Slot would produce an inconsistent or duplicated rendering output.

### New Feature

- `Dropdown` now has a `focusOnMount` prop which is passed directly to the contained `Popover`.

## 7.0.5 (2019-01-03)

## 7.0.4 (2018-12-12)
Expand Down
10 changes: 10 additions & 0 deletions packages/components/src/dropdown/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,13 @@ Opt-in prop to show popovers fullscreen on mobile, pass `false` in this prop to

- Type: `String`
- Required: No

### focusOnMount

By default, the *first tabblable element* in the popover will receive focus when it mounts. This is the same as setting `focusOnMount` to `"firstElement"`. If you want to focus the container instead, you can set `focusOnMount` to `"container"`.

Set this prop to `false` to disable focus changing entirely. This should only be set when an appropriately accessible substitute behavior exists.

- Type: `String` or `Boolean`
- Required: No
- Default: `"firstElement"`
2 changes: 2 additions & 0 deletions packages/components/src/dropdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class Dropdown extends Component {
contentClassName,
expandOnMobile,
headerTitle,
focusOnMount,
} = this.props;

const args = { isOpen, onToggle: this.toggle, onClose: this.close };
Expand All @@ -88,6 +89,7 @@ class Dropdown extends Component {
onClickOutside={ this.closeIfClickOutside }
expandOnMobile={ expandOnMobile }
headerTitle={ headerTitle }
focusOnMount={ focusOnMount }
>
{ renderContent( args ) }
</Popover>
Expand Down