-
Notifications
You must be signed in to change notification settings - Fork 595
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
text field loosing state on render
#579
Comments
@perguth Did you ever find a solution to this? I'm running into the same issue. |
Yes, thanks to the friendly folks 👬 in let Input = class Component extends Nanocomponent {
constructor () {
super()
this.state = {}
}
createElement (state) {
this.state = state
return html`
<input onkeypress=${state.onkeypress} onfocus=${state.onfocus} onblur=${state.onblur}
class=form-control type=text placeholder='name or mac address' data-toggle=dropdown>
`
}
update () {}
}
let input = new Input() (source) and included it like so: ${input.render({onkeypress: search, onfocus: showSuggestions, onblur: hideSuggestions})} (source). Nonetheless this behaviour was considered a 🪲bug. |
Is this a bug in nanomorph? I guess it just needs to not consider |
is there any update on this? my workaround in the meantime is to attach an const inputField = input({type: "text"})
inputField.isSameNode = (target) => {
return (target && target.nodeName && target.nodeName === 'INPUT')
} |
Expected behavior
Input fields should retain their state (and possibly focus as well as cursor position) regardless of
emitter.emit('render')
Actual behavior
Text input fields loose their state/value on rendering.
Steps to reproduce behavior
Minimally adjusted code from the README shows the described behaviour: http://requirebin.com/?gist=829488013f4333ed528825df65c6a406
The text was updated successfully, but these errors were encountered: