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

Button: add focus() method #1740

Closed
Sole-Valero opened this issue Jun 7, 2017 · 1 comment
Closed

Button: add focus() method #1740

Sole-Valero opened this issue Jun 7, 2017 · 1 comment

Comments

@Sole-Valero
Copy link
Contributor

Steps

It is not possible to call focus() method when you hav a ref to an Button component
<Button ref={(button) => this.buttonRef=button} >Select All

This is a similar issue also solved for Input component:
#1475

Expected Result

this.buttonRef.focus() --> send the focus to the button

Actual Result

Uncaught TypeError:this.buttonRef.focus is not a function

@layershifter layershifter changed the title Add focus() method to Button component Button: add focus() method Jun 8, 2017
@levithomason
Copy link
Member

I think focusing a Button is common enough that this makes sense to implement this. Thanks for the idea.

In the meantime, here's a workaround:

const $button = document.querySelector('#my-button')
if ($button) $button.focus()

<Button id='my-button' />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants