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

BUG: select actions does not trigger "input" events (only "change" event) on select inputs/dropdowns #223

Open
cgaube opened this issue Jan 6, 2023 · 0 comments

Comments

@cgaube
Copy link

cgaube commented Jan 6, 2023

Context

When a user change/select the value (option) of a dropdown input :

<label for="test">Trigger events</label>
<select name="test" id="test">
  <option>A</option>
  <option>B</option>
</select>

<script>
const selectInput = document.getElementById('test');

selectInput.addEventListener('change', () => console.log('CHANGE EVENT TRIGGERED));
selectInput.addEventListener('input', () => console.log('input EVENT TRIGGERED));
</script>

in test:

select 'B', from:"Trigger events" 

it does not trigger the input event , but correctly triggers the change event
https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/input_event

Looking at the code i think we are missing a line that also triggers a input event in addition to that change event

changed(node) {
let element;
let event = document.createEvent("HTMLEvents");
event.initEvent("change", true, false);
// In the case of an OPTION tag, the change event should come
// from the parent SELECT
if (node.nodeName == "OPTION") {
element = node.parentNode
if (element.nodeName == "OPTGROUP") {
element = element.parentNode
}
element
} else {
element = node
}
element.dispatchEvent(event)

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