Skip to content
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

mdui-text-area emits "input" event twice #334

Open
stavros-tsioulis opened this issue Jul 29, 2024 · 0 comments
Open

mdui-text-area emits "input" event twice #334

stavros-tsioulis opened this issue Jul 29, 2024 · 0 comments

Comments

@stavros-tsioulis
Copy link

<mdui-text-field id="inputField"></mdui-text-field>

<script>
const textField = window.inputField
textField.addEventListener('input', event => console.log(event.target.value))
</script>

In the above example, each input will trigger a console log twice.
This likely happens because the input event is propagated downwards. For example, this will actually print in the console:

<div oninput="console.log('input')">
  <input />
</div>

Since, on input, the mdui-text-field component also emits an input CustomEvent, I believe this is why the duplication happens.

private onInput() {
this.value = this.inputRef.value!.value;
if (this.isTextarea) {
this.setTextareaHeight();
}
this.emit('input');
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant