Enhancement: Add a focus() (and blur()?) method to mdl-textfield
See original GitHub issueI’m currently battling to make a login form using 2 mdl-textfields and an mdl-button. I’d like the Enter key to move focus to the next text box (e.g. Username to Password), and then from Password to fire the Login button. Getting the keyup events is no problem (@keyup.native="onKeyUp"), but setting focus without resorting to id’s and document.getElementById() is proving tricky. I tried the Vue ref="password" and then using this.$refs.password.$el.focus(), but of course that targets the div which is the parent of the input field, which then ignores the focus request. Or, am I going about this wrong?
If there’s another vmdl component which already does something similar, perhaps now would be a good time to try a pull request. Can you point me at one which does something like this I could look at?
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (2 by maintainers)

Top Related StackOverflow Question
I added these methods, which seem to have the desired effect. In
v-if/v-else-ifsections which generate the actual<input>tag, it appears you can reuse the ‘ref’, so providing you only end up with onefocusTargetref, all is well:@dsl101 Cool, thanks!