import { $$, Component } from '../dom'

export default class Input extends Component {
  didMount () {
    // HACK: for whatever reason, the native autofocus does not work
    // after the first time. This forces focus if autofocus is set
    if (this.el.getAttribute('autofocus') === 'true') {
      this.el.focus()
    }
  }

  render () {
    const attributes = Object.assign({ class: 'sc-input' }, this.props)
    delete attributes.label
    return $$('input', attributes)
  }

  focus () {
    this.getElement().focus()
  }
}

@@ -31,16 +31,51 @@
 '../dom'
+%0Aimport %7B platform %7D from '../util'
 %0A%0Aexport
@@ -345,16 +345,224 @@
 focus()%0A
+      // put the cursor at the end%0A      if (platform.inBrowser) %7B%0A        const val = this.el.val()%0A        if (val) %7B%0A          this.el.getNativeElement().setSelectionRange(0, val.length)%0A        %7D%0A      %7D%0A
     %7D%0A  

Improve Input focus behavior.