Skip to content
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
2 changes: 1 addition & 1 deletion packages/base/src/util/FocusableElements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const findFocusableElement = async (container: HTMLElement, forward: boolean, st
let currentIndex = -1;

if (container.shadowRoot) {
child = forward ? container.shadowRoot.firstChild as HTMLElement : container.shadowRoot.lastChild as HTMLElement;
child = forward ? container.shadowRoot.firstElementChild as HTMLElement : container.shadowRoot.lastElementChild as HTMLElement;
} else if (container instanceof HTMLSlotElement && container.assignedNodes()) {
assignedElements = container.assignedElements();
currentIndex = forward ? 0 : assignedElements.length - 1;
Expand Down
26 changes: 22 additions & 4 deletions packages/main/cypress/specs/F6.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@ import "@ui5/webcomponents-base/dist/features/F6Navigation.js";
import Button from "../../src/Button.js";
import Bar from "../../src/Bar.js";

class MySimpleComponent extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: "open", delegatesFocus: true });

this.shadowRoot.innerHTML = `
<!-- HTML Comment -->
<button onclick="alert('Hello!')">Click Me</button>
<!-- HTML Comment -->
`;
}
}

customElements.define("my-simple-component", MySimpleComponent);

// @ts-ignore
const MySimpleComponentRenderer = () => <my-simple-component id="second" data-sap-ui-fastnavgroup="true">Second focusable</my-simple-component>

describe("F6 navigation", () => {
describe("F6 Forward navigation", () => {
it("tests navigation", () => {
Expand All @@ -16,8 +34,8 @@ describe("F6 navigation", () => {
<div class="section">
<Button>Something focusable</Button>
</div>
<div class="section" data-sap-ui-fastnavgroup="true">
<Button id="second">Second focusable</Button>
<div class="section">
<MySimpleComponentRenderer />
</div>
<div class="section">
<Button>Something focusable</Button>
Expand Down Expand Up @@ -431,8 +449,8 @@ describe("F6 navigation", () => {
<div class="section">
<Button>Something focusable</Button>
</div>
<div class="section" data-sap-ui-fastnavgroup="true">
<Button id="second">Second focusable</Button>
<div class="section">
<MySimpleComponentRenderer />
</div>
<div class="section">
<Button>Something focusable</Button>
Expand Down
Loading