ui: Remove string casting when passing index/checked for dropmenus (#9077)

* ui: Remove string casting when passing index/checked

* Check for e.target
This commit is contained in:
John Cowen 2020-11-02 16:07:08 +00:00 committed by hashicorp-ci
parent 2ac2930b39
commit e2c6e4d069
3 changed files with 3 additions and 6 deletions

View File

@ -71,7 +71,7 @@ export default Component.extend(Slotted, {
return this.dom.clickFirstAnchor(e, '.list-collection > ul > li');
},
change: function(index, e = {}) {
if (e.target.checked && index != get(this, 'checked')) {
if (e.target.checked && index !== get(this, 'checked')) {
set(this, 'checked', parseInt(index));
this.$row = this.dom.closest('li', e.target);
this.$row.style.zIndex = 1;

View File

@ -18,7 +18,7 @@
<YieldSlot @name="row">{{yield cell.item index}}</YieldSlot>
{{#if hasActions }}
<td class="actions">
<YieldSlot @name="actions" @params={{block-params (concat cell.index) (action "change") checked}}>
<YieldSlot @name="actions" @params={{block-params cell.index (action "change") checked}}>
{{yield cell.item index}}
</YieldSlot>
</td>

View File

@ -95,13 +95,10 @@ export default CollectionComponent.extend(Slotted, {
return this.dom.clickFirstAnchor(e);
},
change: function(index, e = {}) {
if (typeof index !== 'string') {
return;
}
if (this.$tr) {
this.$tr.style.zIndex = null;
}
if (e.target.checked && index != get(this, 'checked')) {
if (e.target && e.target.checked && index !== get(this, 'checked')) {
set(this, 'checked', parseInt(index));
const target = e.target;
const $tr = this.dom.closest('tr', target);