Merge pull request #728 from MathieuPuech/fix/724-select-rich-preventDefault

fix(select-rich): prevent scrolling when focused
This commit is contained in:
Joren Broekema 2020-05-27 16:32:22 +02:00 committed by GitHub
commit 641ec01681
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -69,6 +69,30 @@ export class LionSelectInvoker extends LionButton {
this.type = 'button';
}
connectedCallback() {
if (super.connectedCallback) {
super.connectedCallback();
}
const handleKeydown = event => {
switch (event.key) {
case 'ArrowDown':
case 'ArrowUp':
event.preventDefault();
/* no default */
}
};
this.handleKeydown = handleKeydown;
this.addEventListener('keydown', this.handleKeydown);
}
disconnectedCallback() {
if (super.disconnectedCallback) {
super.disconnectedCallback();
}
this.removeEventListener('keydown', this.handleKeydown);
}
_contentTemplate() {
if (this.selectedElement) {
const labelNodes = Array.from(this.selectedElement.querySelectorAll('*'));