Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/22752.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:feature
consul-ui: fixes the issue where when doing deletes of multiple tokens or policies, the three dots on the right hand side stops responding after the first delete.
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/hashicorp/consul/blob/main/docs/contributing/add-a-changelog-entry.md
Follow this guide for the changelog.
Here type is bug and code area is ui

Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<YieldSlot @name="details"><div class="detail">{{yield cell.item cell.index}}</div></YieldSlot>
<YieldSlot @name="actions"
@params={{
block-params (component 'more-popover-menu' expanded=(if (eq checked cell.index) true false) onchange=(action "change" cell.index))
block-params (component 'more-popover-menu' expanded=(if (eq checked cell.item.uid) true false) onchange=(action "change" cell.item.uid))
}}
>
<div class="actions">
Expand All @@ -51,13 +51,13 @@
<li
data-test-list-row
onclick={{action 'click'}}
class={{if (not linkable) 'linkable' (if (is linkable item=cell.item) 'linkable')}}
class={{if (not linkable) 'linkable' (if (is linkable item=item) 'linkable')}}
>
<YieldSlot @name="header"><div class="header">{{yield item index}}</div></YieldSlot>
<YieldSlot @name="details"><div class="detail">{{yield item index}}</div></YieldSlot>
<YieldSlot @name="actions"
@params={{
block-params (component 'more-popover-menu' onchange=(action "change" index))
block-params (component 'more-popover-menu' onchange=(action "change" item.uid))
}}
>
<div class="actions">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export default Component.extend(Slotted, {
const o = this;
this['cell-layout'].formatItemStyle = function (itemIndex) {
let style = formatItemStyle.apply(this, arguments);
if (o.checked === itemIndex) {
const items = get(o, 'items');
if (items && items[itemIndex] && o.checked === items[itemIndex].uid) {
style = `${style};z-index: 1`;
}
return style;
Expand Down Expand Up @@ -75,7 +76,7 @@ export default Component.extend(Slotted, {
},
change: function (index, e = {}) {
if (e.target.checked && index !== this.checked) {
set(this, 'checked', parseInt(index));
set(this, 'checked', index);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a test to cover this behaviour?

this.$row = this.dom.closest('li', e.target);
this.$row.style.zIndex = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import { render, triggerEvent } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';

module('Integration | Component | list collection', function (hooks) {
Expand All @@ -26,4 +26,48 @@ module('Integration | Component | list collection', function (hooks) {

assert.dom('*').hasText('');
});

test('it manages checked state and z-index on change', async function (assert) {
this.set('items', [
{ id: 1, name: 'Item 1' },
{ id: 2, name: 'Item 2' },
]);

// Add a footer for collision detection
const footer = document.createElement('footer');
footer.setAttribute('role', 'contentinfo');
footer.style.position = 'fixed';
footer.style.bottom = '0';
footer.style.height = '50px';
document.body.appendChild(footer);

await render(hbs`
<ListCollection @items={{this.items}} as |item index Actions|>
<BlockSlot @name="header">{{item.name}}</BlockSlot>
<BlockSlot @name="actions" as |Actions|>
<Actions as |Action|>
<Action>
<BlockSlot @name="label">Action</BlockSlot>
</Action>
</Actions>
</BlockSlot>
</ListCollection>
`);

const checkbox = this.element.querySelector('input[type="checkbox"]');
const row = this.element.querySelector('[data-test-list-row]');

// Test checking - should set z-index and handle footer collision
checkbox.checked = true;
await triggerEvent(checkbox, 'change');
assert.equal(row.style.zIndex, '1', 'Row should have z-index 1 when checked');

// Test unchecking - should clear z-index
checkbox.checked = false;
await triggerEvent(checkbox, 'change');
assert.strictEqual(row.style.zIndex, '', 'Row z-index should be cleared when unchecked');

// Cleanup
document.body.removeChild(footer);
});
});
Loading