Skip to content

Commit

Permalink
QFIX: undefined exception (#7716)
Browse files Browse the repository at this point in the history
  • Loading branch information
haiodo authored Jan 20, 2025
1 parent 2613e62 commit 599b7b3
Showing 1 changed file with 31 additions and 19 deletions.
50 changes: 31 additions & 19 deletions plugins/view-resources/src/components/list/ListCategories.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -228,18 +228,22 @@
if (listListCategory?.[0] == null) {
return
}
const obj = listListCategory[0].getLimited()[0]
listListCategory[0].expand()
select(0, obj)
const obj = listListCategory[0]?.getLimited()?.[0]
if (obj !== undefined) {
listListCategory[0]?.expand()
select(0, obj)
}
return
} else {
if (listListCategory?.[0] == null) {
return
}
const g = listListCategory[categories.length - 1].getLimited()
listListCategory[categories.length - 1].expand()
const obj = g[g.length - 1]
select(0, obj)
const g = listListCategory[categories.length - 1]?.getLimited() ?? []
if (g.length > 0) {
listListCategory[categories.length - 1].expand()
const obj = g[g.length - 1]
select(0, obj)
}
return
}
} else {
Expand Down Expand Up @@ -297,25 +301,29 @@
if (dir === undefined || dir === 'vertical') {
if (statePos - 1 < 0 && objState >= 0) {
if (objState !== 0) {
const pstateObjs = listListCategory[objState - 1].getLimited()
dispatch('select', pstateObjs[pstateObjs.length - 1])
const pstateObjs = listListCategory[objState - 1]?.getLimited()
if (pstateObjs !== undefined) {
dispatch('select', pstateObjs[pstateObjs.length - 1])
}
} else {
dispatch('select-prev', stateObjs[statePos])
}
} else {
const obj = stateObjs[statePos - 1]
if (obj !== undefined) {
const focusDoc = listListCategory[objState]?.getLimited().find((it) => it._id === obj._id) ?? obj
if (!noScroll) scrollInto(objState, focusDoc)
dispatch('row-focus', focusDoc)
const focusDoc = listListCategory[objState]?.getLimited()?.find((it) => it._id === obj._id) ?? obj
if (focusDoc !== undefined) {
if (!noScroll) scrollInto(objState, focusDoc)
dispatch('row-focus', focusDoc)
}
}
}
return
}
}
if (offset === 1) {
if (dir === undefined || dir === 'vertical') {
const limited = listListCategory[objState].getLimited()
const limited = listListCategory[objState]?.getLimited() ?? []
if (statePos + 1 >= limited.length && objState < categories.length) {
if (objState + 1 !== categories.length) {
const pstateObjs = getGroupByValues(groupByDocs, categories[objState + 1])
Expand All @@ -326,18 +334,22 @@
} else {
const obj = stateObjs[statePos + 1]
if (obj !== undefined) {
const focusDoc = listListCategory[objState]?.getLimited().find((it) => it._id === obj._id) ?? obj
if (!noScroll) scrollInto(objState, focusDoc)
dispatch('row-focus', focusDoc)
const focusDoc = listListCategory[objState]?.getLimited()?.find((it) => it._id === obj._id) ?? obj
if (focusDoc !== undefined) {
if (!noScroll) scrollInto(objState, focusDoc)
dispatch('row-focus', focusDoc)
}
}
}
return
}
}
if (offset === 0) {
const focusDoc = listListCategory[objState]?.getLimited().find((it) => it._id === obj._id) ?? obj
if (!noScroll) scrollInto(objState, focusDoc)
dispatch('row-focus', focusDoc)
const focusDoc = listListCategory[objState]?.getLimited()?.find((it) => it._id === obj._id) ?? obj
if (focusDoc !== undefined) {
if (!noScroll) scrollInto(objState, focusDoc)
dispatch('row-focus', focusDoc)
}
}
} else {
listCategory[objState]?.select(offset, of, dir, noScroll)
Expand Down

0 comments on commit 599b7b3

Please sign in to comment.