Closed purezen closed 8 years ago
Hi, maybe this example help you.
_executeAfterModalOpen(){
this.refs.myInput.focus();
}
<SkyLight afterOpen={this._executeAfterModalOpen}><input ref='myInput' type='text' /></SkyLight>
Please, let me know if that works :+1:
Well, that's what I have been trying. But still doesn't work.
Hey, can you confirm if that is working? Coz, for me this
inside _executeAfterModelOpen() is pointing to something else.
Object {
hideOnOverlayClicked: true,
afterOpen: wrapMethod/<(),
dialogStyles: Object,
title: "Improve task",
children: Object,
showOverlay: true,
overlayStyles: Object,
closeButtonStyle: Object
}
Hi, I have been trying to implement autofocus on a text input field inside a modal. I started by calling
focus()
on the element inside the_executeAfterModalOpen()
callback. An alert function inside the callback is working fine. But it looks likethis
inside the callback is not pointing to the component. So,this.refs
is showing up aswhich I am trying to use to get hold of the input field in turn doing_unassigned_
this.refs.modal.focus()
.EDIT: I meant
this.refs
is showing up asundefined
.