Skip to content

Commit f1ce974

Browse files
authored
fix(ui5-timeline): implement arrows navigation for inner elements (#12033)
fixes #11785
1 parent 39f8e66 commit f1ce974

File tree

3 files changed

+44
-4
lines changed

3 files changed

+44
-4
lines changed

packages/fiori/cypress/specs/Timeline.cy.tsx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import messageInformation from "@ui5/webcomponents-icons/dist/message-informatio
77
import Label from "@ui5/webcomponents/dist/Label.js";
88
import Avatar from "@ui5/webcomponents/dist/Avatar.js";
99
import UI5Element from "@ui5/webcomponents-base";
10+
import Input from "@ui5/webcomponents/dist/Input.js";
1011

1112
function Sample() {
1213
return <Timeline layout="Vertical" accessibleName="vertical" id="timelineAccName">
@@ -261,6 +262,41 @@ describe("Timeline with growing mode", () => {
261262
.last()
262263
.should("be.focused");
263264
});
265+
266+
it("Arrows navigation should work only on focused item", () => {
267+
cy.mount(
268+
<Timeline>
269+
<TimelineItem titleText="first item"></TimelineItem>
270+
<TimelineItem titleText="second item">
271+
<Input id="input" />
272+
</TimelineItem>
273+
<TimelineItem titleText="last item"></TimelineItem>
274+
</Timeline>
275+
);
276+
277+
cy.get("[ui5-timeline]")
278+
.as("timeline");
279+
280+
cy.get("#input")
281+
.realClick();
282+
283+
cy.realPress("ArrowDown");
284+
285+
cy.get("@timeline")
286+
.find("ui5-timeline-item")
287+
.last()
288+
.should("not.be.focused");
289+
290+
cy.get("#input")
291+
.realClick();
292+
293+
cy.realPress("ArrowUp");
294+
295+
cy.get("@timeline")
296+
.find("ui5-timeline-item")
297+
.first()
298+
.should("not.be.focused");
299+
});
264300
});
265301

266302
describe("Accessibility", () => {

packages/fiori/src/Timeline.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,15 +354,17 @@ class Timeline extends UI5Element {
354354
}
355355

356356
_onkeydown(e: KeyboardEvent) {
357-
const target = e.target as ITimelineItem;
357+
const target = e.target as ITimelineItem,
358+
targetfocusDomRef = target?.getFocusDomRef(),
359+
shouldHandleCustomArrowNavigation = targetfocusDomRef === this.getFocusDomRef() || target === this.growingButton;
358360

359-
if (isDown(e) || isRight(e)) {
361+
if (shouldHandleCustomArrowNavigation && (isDown(e) || isRight(e))) {
360362
this._handleDown();
361363
e.preventDefault();
362364
return;
363365
}
364366

365-
if (isUp(e) || isLeft(e)) {
367+
if (shouldHandleCustomArrowNavigation && (isUp(e) || isLeft(e))) {
366368
this._handleUp(e);
367369
e.preventDefault();
368370
return;

packages/fiori/test/pages/Timeline.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ <h2>Timeline within Card Vertical</h2>
2727
</ui5-card-header>
2828
<ui5-timeline layout="Vertical" accessible-name="vertical" id="timelineAccName">
2929
<ui5-timeline-item title-text="called" subtitle-text="20.02.2017 11:30" icon="phone"
30-
name="Stanislava Baltova" name-clickable></ui5-timeline-item>
30+
name="Stanislava Baltova" name-clickable>
31+
<ui5-input value="Input"></ui5-input>
32+
</ui5-timeline-item>
3133
<ui5-timeline-item title-text="called" subtitle-text="20.02.2017 11:30" icon="phone"
3234
name="Stanislava Baltova"></ui5-timeline-item>
3335
<ui5-timeline-item title-text="Weekly Sync - CP Design"

0 commit comments

Comments
 (0)