Skip to content

Commit 3f271a0

Browse files
Andrey Okonetchnikovokonet
authored andcommitted
feat(focus): Introduce public method focus
1 parent aa24f0d commit 3f271a0

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/FocusWithin.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@ class FocusWithin extends React.Component {
1212

1313
ref = React.createRef()
1414

15+
/** @public
16+
* @function focus - calls `focus` method on the container node
17+
* @return void
18+
* */
19+
focus() {
20+
const node = this.ref.current
21+
if (node != null && typeof node.focus === 'function') {
22+
node.focus()
23+
}
24+
}
25+
1526
onFocus = evt => {
1627
const { onFocus } = this.props
1728
const { focused } = this.state

0 commit comments

Comments
 (0)