Browse Source

fix: reset offset count when closing modal or when filter query changes

pull/7942/head
Pranav C 8 months ago
parent
commit
d2036dc7be
  1. 15
      packages/nc-gui/components/virtual-cell/components/LinkedItems.vue
  2. 1
      packages/nc-gui/components/virtual-cell/components/UnLinkedItems.vue
  3. 7
      packages/nc-gui/composables/useLTARStore.ts

15
packages/nc-gui/components/virtual-cell/components/LinkedItems.vue

@ -59,6 +59,7 @@ const {
link, link,
meta, meta,
headerDisplayValue, headerDisplayValue,
resetChildrenListOffsetCount,
} = useLTARStoreOrThrow() } = useLTARStoreOrThrow()
const { isNew, state, removeLTARRef, addLTARRef } = useSmartsheetRowStoreOrThrow() const { isNew, state, removeLTARRef, addLTARRef } = useSmartsheetRowStoreOrThrow()
@ -69,6 +70,11 @@ watch(
if ((nextVal[0] || nextVal[1]) && !isNew.value) { if ((nextVal[0] || nextVal[1]) && !isNew.value) {
loadChildrenList() loadChildrenList()
} }
// reset offset count when closing modal
if (!nextVal[0]) {
resetChildrenListOffsetCount()
}
}, },
{ immediate: true }, { immediate: true },
) )
@ -207,9 +213,16 @@ watch(childrenListPagination, () => {
}) })
onUnmounted(() => { onUnmounted(() => {
resetChildrenListOffsetCount()
childrenListPagination.query = '' childrenListPagination.query = ''
window.removeEventListener('keydown', linkedShortcuts) window.removeEventListener('keydown', linkedShortcuts)
}) })
const onFilterChange = () => {
childrenListPagination.page = 1
// reset offset count when filter changes
resetChildrenListOffsetCount()
}
</script> </script>
<template> <template>
@ -242,7 +255,7 @@ onUnmounted(() => {
:placeholder="`Search in ${relatedTableMeta?.title}`" :placeholder="`Search in ${relatedTableMeta?.title}`"
class="w-full !sm:rounded-md xs:min-h-8 !xs:rounded-xl" class="w-full !sm:rounded-md xs:min-h-8 !xs:rounded-xl"
size="small" size="small"
@change="childrenListPagination.page = 1" @change="onFilterChange"
@keydown.capture.stop=" @keydown.capture.stop="
(e) => { (e) => {
if (e.key === 'Escape') { if (e.key === 'Escape') {

1
packages/nc-gui/components/virtual-cell/components/UnLinkedItems.vue

@ -256,6 +256,7 @@ onMounted(() => {
}) })
onUnmounted(() => { onUnmounted(() => {
resetChildrenExcludedOffsetCount()
childrenExcludedListPagination.query = '' childrenExcludedListPagination.query = ''
window.removeEventListener('keydown', linkedShortcuts) window.removeEventListener('keydown', linkedShortcuts)
}) })

7
packages/nc-gui/composables/useLTARStore.ts

@ -554,6 +554,10 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState(
childrenExcludedOffsetCount.value = 0; childrenExcludedOffsetCount.value = 0;
} }
const resetChildrenListOffsetCount = () => {
childrenListOffsetCount.value = 0
}
return { return {
relatedTableMeta, relatedTableMeta,
loadRelatedTableMeta, loadRelatedTableMeta,
@ -584,7 +588,8 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState(
getRelatedTableRowId, getRelatedTableRowId,
headerDisplayValue, headerDisplayValue,
relatedTableDisplayValuePropId, relatedTableDisplayValuePropId,
resetChildrenExcludedOffsetCount resetChildrenExcludedOffsetCount,
resetChildrenListOffsetCount,
} }
}, },
'ltar-store', 'ltar-store',

Loading…
Cancel
Save