diff --git a/front/core/components/icon-button/icon-button.js b/front/core/components/icon-button/icon-button.js index b4022ccec..ba3ccae3e 100644 --- a/front/core/components/icon-button/icon-button.js +++ b/front/core/components/icon-button/icon-button.js @@ -3,23 +3,28 @@ import './style.scss'; export default class IconButton { constructor($element) { - if ($element[0].getAttribute('tabindex') == null) - $element[0].tabIndex = 0; + this.element = $element[0]; - $element.on('keyup', event => this.onKeyDown(event, $element)); - let button = $element[0].querySelector('button'); - $element[0].addEventListener('click', event => { - if (this.disabled || button.disabled) - event.stopImmediatePropagation(); - }); + if (this.element.getAttribute('tabindex') == null) + this.element.tabIndex = 0; + + this.element.addEventListener('keyup', e => this.onKeyup(e)); + this.element.addEventListener('click', e => this.onClick(e)); } - onKeyDown(event, $element) { + onKeyup(event) { + if (event.code == 'Space') + this.onClick(event); + } + + onClick(event) { if (event.defaultPrevented) return; - if (event.keyCode == 13) { - event.preventDefault(); - $element.triggerHandler('click'); - } + event.preventDefault(); + + // FIXME: Don't use Event.stopPropagation() + let button = this.element.querySelector('button'); + if (this.disabled || button.disabled) + event.stopImmediatePropagation(); } } diff --git a/front/core/components/treeview/childs.html b/front/core/components/treeview/childs.html index cd0c59ec0..e185f44db 100644 --- a/front/core/components/treeview/childs.html +++ b/front/core/components/treeview/childs.html @@ -1,69 +1,42 @@ -