Skip to content

Commit f79d2f2

Browse files
GDamyanovilhan007
authored andcommitted
fix(ui5-timeline): implement arrows navigation for inner elements (#12033)
fixes #11785
1 parent 55ad4ae commit f79d2f2

File tree

3 files changed

+40
-3
lines changed

3 files changed

+40
-3
lines changed

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,41 @@ describe("Timeline with growing mode", () => {
265265
.last()
266266
.should("be.focused");
267267
});
268+
269+
it("Arrows navigation should work only on focused item", () => {
270+
cy.mount(
271+
<Timeline>
272+
<TimelineItem titleText="first item"></TimelineItem>
273+
<TimelineItem titleText="second item">
274+
<Input id="input" />
275+
</TimelineItem>
276+
<TimelineItem titleText="last item"></TimelineItem>
277+
</Timeline>
278+
);
279+
280+
cy.get("[ui5-timeline]")
281+
.as("timeline");
282+
283+
cy.get("#input")
284+
.realClick();
285+
286+
cy.realPress("ArrowDown");
287+
288+
cy.get("@timeline")
289+
.find("ui5-timeline-item")
290+
.last()
291+
.should("not.be.focused");
292+
293+
cy.get("#input")
294+
.realClick();
295+
296+
cy.realPress("ArrowUp");
297+
298+
cy.get("@timeline")
299+
.find("ui5-timeline-item")
300+
.first()
301+
.should("not.be.focused");
302+
});
268303
});
269304

270305
describe("Keyboard interactions", () => {

packages/fiori/src/Timeline.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,13 +359,13 @@ class Timeline extends UI5Element {
359359
targetfocusDomRef = target?.getFocusDomRef(),
360360
shouldHandleCustomArrowNavigation = targetfocusDomRef === this.getFocusDomRef() || target === this.growingButton;
361361

362-
if (isDown(e) || isRight(e)) {
362+
if (shouldHandleCustomArrowNavigation && (isDown(e) || isRight(e))) {
363363
this._handleDown();
364364
e.preventDefault();
365365
return;
366366
}
367367

368-
if (isUp(e) || isLeft(e)) {
368+
if (shouldHandleCustomArrowNavigation && (isUp(e) || isLeft(e))) {
369369
this._handleUp(e);
370370
e.preventDefault();
371371
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)