Skip to content

Commit

Permalink
Dropdown: add focusOnMount prop to pass onto Popover component (#12855)
Browse files Browse the repository at this point in the history
  • Loading branch information
psealock authored and youknowriad committed Mar 6, 2019
1 parent 8519c1a commit 9066f1f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
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

0 comments on commit 9066f1f

Please sign in to comment.