How to programmatically clear PaperInput and have the floating label drop down to the input line

前端 未结 1 859
时光取名叫无心
时光取名叫无心 2020-12-21 20:06

I have the following markup:



        
相关标签:
1条回答
  • 2020-12-21 20:42

    It seems you need to call blur on the actual <input id='input'> element inside <paper-input> not the <paper-input> itself.
    I got it working with

    import 'dart:js' as js;
    
    var inp = $['alias-input'] as PaperInput;
    inp.inputValue = '';
    new js.JsObject.fromBrowserObject(inp).callMethod('inputBlurAction', []);
    

    alternatively you can do it like

    var inp = $['alias-input'] as PaperInput;
    inp.inputValue = '';
    inp.querySelector('* /deep/ #input') // not yet supported with polyfills
    ..focus() // blur doesn't work when the field doesn't have the focus
    ..blur();
    
    0 讨论(0)
提交回复
热议问题