Skip to content
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

feat(ui5-list): add DELETE shortcut key #3226

Merged
merged 1 commit into from
May 12, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions packages/main/src/ListItem.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
{{#if modeDelete}}
<div class="ui5-li-deletebtn">
<ui5-button
tabindex="-1"
id="{{_id}}-deleteSelectionElement"
design="Transparent"
icon="decline"
Expand Down
6 changes: 5 additions & 1 deletion packages/main/src/ListItem.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isSpace, isEnter } from "@ui5/webcomponents-base/dist/Keys.js";
import { isSpace, isEnter, isDelete } from "@ui5/webcomponents-base/dist/Keys.js";
import "@ui5/webcomponents-icons/dist/decline.js";
import "@ui5/webcomponents-icons/dist/edit.js";
import { fetchI18nBundle, getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js";
Expand Down Expand Up @@ -177,6 +177,10 @@ class ListItem extends ListItemBase {
if (isSpace(event)) {
this.fireItemPress(event);
}

if (this.modeDelete && isDelete(event)) {
this.onDelete();
}
}

_onmousedown(event) {
Expand Down
15 changes: 14 additions & 1 deletion packages/main/test/specs/List.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,19 @@ describe("List Tests", () => {
assert.equal(browser.$('#lblResult').getHTML(false), "Laptop HP: 1", "itemDelete event was fired for the right item");
});

it("mode: delete. DELETE key press - deletes item", () => {
browser.url(`http://localhost:${PORT}/test-resources/pages/List_test_page.html`);
list.root.setProperty("mode", "Delete");

const firstItem = list.getItem(0);
firstItem.click();

assert.ok(!firstItem.getAttribute("selected"), "item is selected");

firstItem.keys("Delete")
assert.equal(browser.$('#lblResult').getHTML(false), "Laptop HP: 1", "itemDelete event was fired for the right item");
});

it("item size and classed, when an item has both text and description", () => {
const ITEM_WITH_DESCRIPTION_AND_TITLE_HEIGHT = 80;
const firstItem = $("#listWithDesc ui5-li:first-child");
Expand Down Expand Up @@ -355,7 +368,7 @@ describe("List Tests", () => {
assert.strictEqual(item3.getProperty("focused"), true, "disabled item is skipped");
});

it.only('should focus next interactive element if TAB is pressed when focus is on "More" growing button', () => {
it('should focus next interactive element if TAB is pressed when focus is on "More" growing button', () => {
const growingListButton = $('#growingListButton').shadow$("div[load-more-inner]");
const nextInteractiveElement = $('#nextInteractiveElement');

Expand Down