-
Notifications
You must be signed in to change notification settings - Fork 296
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
[listbox|select-rich|combobox] select-rich model-value-changed dispatched on keyboard navigation #708
Comments
By default, it mimics the platform interaction (of On which platform did you test? If it is on |
Fair point. I will later spin up a vm to do a test with a native select on windows and see if we're doing the right thing here :) |
Tested it. You're right about an opened select. What happens:
Currently, we also sync an opened select to the invoker realtime, hence the I will mark this as a bug/improvement |
May I ask if that's still a concern? Is there any workaround I can apply, as a subclasser? Thanks! |
there issue is still here, in our subclass, we have added a setCheckedIndex(index) {
super.setCheckedIndex(index);
if (this.formElements[index] && this.__oldIndex !== index) {
if (!this.opened) {
this.__oldIndex = index;
this.dispatchEvent(new CustomEvent('change', { bubbles: true }));
}
}
} |
@MathieuPuech Nice 👍 We could incorporate this into our core, so that we get similar behavior for all listboxes(listbox/combobox/select-rich) and choice groups in general (meaning radio-groups/checkbox-groups) as well. To make it work for all those components, we could check for We could add something like @ffoodd @MathieuPuech Then you could make a generic mixin for your extension layer (N.B. this is a proposal, not implemented yet): const ExtionsionLayerFormControlMixin = (superclass) => ExtionsionLayerFormControl extends superclass {
constructor() {
super();
this.addEventListener('model-value-changed', (ev) => {
if (ev.detail.isTriggeredAfterBlur) {
this.dispatchEvent(new CustomEvent('change', { bubbles: true }));
}
});
}
} Or we could consider to add this by default in v1 as well for better DX: <form-control @change="${onChangeAfterBlur}" @input="${onUserInput}" @value="${onProgrammaticChange}"> |
Related discussion: #24 |
Describe the bug
When you select a value with keyboard, the model-value-changed event is dispatched before the user validate the selection.
On native select, the change event is dispatched only when Enter key is pressed.
I saw an error on the documentation too: instead of
model-value-changed
event, it'sselect-model-value-changed
(see https://lion-web-components.netlify.app/?path=/docs/forms-select-rich--render-options)To Reproduce
Steps to reproduce the behavior:
document.querySelector('lion-select-rich').addEventListener('model-value-changed', console.log)
Expected behavior
Event should not be dispatched before the value is selected
The text was updated successfully, but these errors were encountered: