Skip to content

Commit

Permalink
refactor(ui5-li-group): forward focused attribute to header item (#8978)
Browse files Browse the repository at this point in the history
fix(ui5-li-group): forward focused attribute to header item

Introduce focused attribute to implement fake focus feature in suggestion items.
  • Loading branch information
dobrinyonkov authored May 17, 2024
1 parent 410ba3f commit fabe257
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 12 deletions.
24 changes: 12 additions & 12 deletions packages/main/src/ListItemGroup.hbs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<ul class="ui5-group-li-root" role="group">
{{#if hasHeader}}
<ui5-li-group-header part="header">
{{#if hasFormattedHeader}}
<slot name="header"></slot>
{{else}}
{{headerText}}
{{/if}}
</ui5-li-group-header>
{{/if}}
<slot></slot>
</ul>
<ul class="ui5-group-li-root" role="group">
{{#if hasHeader}}
<ui5-li-group-header ?focused="{{focused}}" part="header">
{{#if hasFormattedHeader}}
<slot name="header"></slot>
{{else}}
{{headerText}}
{{/if}}
</ui5-li-group-header>
{{/if}}
<slot></slot>
</ul>
7 changes: 7 additions & 0 deletions packages/main/src/ListItemGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ class ListItemGroup extends UI5Element {
})
items!: Array<ListItemBase>;

/**
* Indicates whether the header is focused
* @private
*/
@property({ type: Boolean })
focused!: boolean;

/**
* Defines the header of the component.
*
Expand Down
31 changes: 31 additions & 0 deletions packages/main/test/specs/ListItemGroup.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { assert } from "chai";

describe("ListItemGroup Tests", () => {
before(async () => {
await browser.url(`test/pages/List_test_page.html`);
});

it("ListGroup is rendered", async () => {
const listItemGroup = await browser.$("#list1 [ui5-li-group]");
const listItemGroupHeader = await listItemGroup.shadow$("ui5-li-group-header");

assert.ok(listItemGroup.isExisting(), true, "ListGroup is rendered");
assert.ok(listItemGroupHeader.isExisting(), true, "ListGroup header is rendered");
});

it("ListGroup renders header-text property correctly", async () => {
const listItemGroup = await browser.$("#list1 [ui5-li-group]");
const listItemGroupHeader = await listItemGroup.shadow$("ui5-li-group-header");

assert.strictEqual(await listItemGroupHeader.getText(), "New Items", "List's group header is correctly displayed");
});

it("ListGroup propagates focused property to header item", async () => {
const listItemGroup = await browser.$("#list1 [ui5-li-group]");
const listItemGroupHeader = await listItemGroup.shadow$("ui5-li-group-header");

await listItemGroup.setProperty("focused", true);
assert.strictEqual(await listItemGroupHeader.getProperty("focused"), true, "List's group header is focused");
await listItemGroup.setProperty("focused", false);
});
});

0 comments on commit fabe257

Please sign in to comment.