Skip to content

Commit bafee68

Browse files
committed
ISSUE #4585 - exiting from last item in the list when it is filtered out does not select first item
1 parent 29824c7 commit bafee68

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

frontend/src/v4/routes/viewerGui/components/issues/components/issueDetails/issueDetails.component.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,9 @@ export class IssueDetails extends PureComponent<IProps, IState> {
239239
// item is part of the filtered items list, no action required
240240
return;
241241
}
242+
const { listIndex } = this.state;
242243

243-
if (filteredIssues.length) {
244-
const { listIndex } = this.state;
244+
if (filteredIssues.length && listIndex < filteredIssues.length) {
245245
// set next item in the list as active
246246
setActiveIssue(filteredIssues[listIndex % filteredIssues.length], revision, false);
247247
return;

frontend/src/v4/routes/viewerGui/components/risks/components/riskDetails/riskDetails.component.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@ export class RiskDetails extends PureComponent<IProps, IState> {
244244
return;
245245
}
246246

247-
if (filteredRisks.length) {
248-
const { listIndex } = this.state;
247+
const { listIndex } = this.state;
248+
if (filteredRisks.length && listIndex < filteredRisks.length) {
249249
// set next item in the list as active
250250
setActiveRisk(filteredRisks[listIndex % filteredRisks.length], revision, false);
251251
return;

frontend/src/v5/ui/routes/viewer/tickets/ticketDetails/ticketsDetailsCard.component.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ export const TicketDetailsCard = () => {
6161

6262
const getUpdatedIndex = (delta: IndexChange) => {
6363
let index = currentIndex === -1 ? initialIndex.current : currentIndex;
64-
if (currentIndex === -1 && delta === IndexChange.NEXT) index -= 1;
64+
if (currentIndex === -1 && delta === IndexChange.NEXT) {
65+
index--;
66+
}
6567
return (index + delta) % filteredTickets.length;
6668
};
6769

@@ -75,8 +77,9 @@ export const TicketDetailsCard = () => {
7577

7678
const goBack = () => {
7779
TicketsCardActionsDispatchers.setCardView(TicketsCardViews.List);
78-
if (currentIndex !== -1) return;
79-
cycleToPrevTicket();
80+
if (currentIndex === -1) {
81+
TicketsCardActionsDispatchers.setSelectedTicket(null);
82+
}
8083
};
8184

8285
const formData = useForm({

0 commit comments

Comments
 (0)