Skip to content

Commit 96ee3d4

Browse files
Calculate and set UsersTable min height to prevent constant shrinking when loading
1 parent c61b130 commit 96ee3d4

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

kolibri/plugins/facility/assets/src/views/users/common/UsersTable.vue

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
:rows="tableRows"
7171
:dataLoading="dataLoading"
7272
:emptyMessage="getEmptyMessageForItems(facilityUsers)"
73+
:style="{ minHeight: tableMinHeight + 'px' }"
7374
sortable
7475
disableBuiltinSorting
7576
@changeSort="changeSortHandler"
@@ -189,7 +190,7 @@
189190
import store from 'kolibri/store';
190191
import cloneDeep from 'lodash/cloneDeep';
191192
import useNow from 'kolibri/composables/useNow';
192-
import { toRefs, ref, computed, onBeforeUnmount, getCurrentInstance } from 'vue';
193+
import { toRefs, ref, computed, onBeforeUnmount, onBeforeUpdate, getCurrentInstance } from 'vue';
193194
import { useRoute, useRouter } from 'vue-router/composables';
194195
import pickBy from 'lodash/pickBy';
195196
import debounce from 'lodash/debounce';
@@ -206,6 +207,7 @@
206207
import PaginatedListContainerWithBackend from 'kolibri-common/components/PaginatedListContainerWithBackend';
207208
import useUser from 'kolibri/composables/useUser';
208209
import useKResponsiveWindow from 'kolibri-design-system/lib/composables/useKResponsiveWindow';
210+
import useKResponsiveElement from 'kolibri-design-system/lib/composables/useKResponsiveElement';
209211
import { themeTokens } from 'kolibri-design-system/lib/styles/theme';
210212
211213
import { Modals } from '../../../constants';
@@ -245,6 +247,8 @@
245247
const modalShown = ref(null);
246248
const userToChange = ref(null);
247249
const filterTextboxRef = ref(null);
250+
const tableMinHeight = ref(200);
251+
const { elementHeight } = useKResponsiveElement();
248252
249253
const { selectAllLabel$ } = enhancedQuizManagementStrings;
250254
const {
@@ -611,6 +615,21 @@
611615
}
612616
};
613617
618+
const getTableHeight = () => {
619+
if (elementHeight.value && facilityUsers.value) {
620+
// Set min-height to elementHeight if there are enough users to scroll the table
621+
if (facilityUsers.value.length > 10) {
622+
tableMinHeight.value = elementHeight.value - 100; // minus 100 to prevent inner scrollbar from appearing
623+
} else {
624+
tableMinHeight.value = 200;
625+
}
626+
}
627+
};
628+
629+
onBeforeUpdate(() => {
630+
getTableHeight();
631+
});
632+
614633
onBeforeUnmount(() => {
615634
const { query } = route;
616635
if (query.ordering || query.order || query.page) {
@@ -647,6 +666,7 @@
647666
userToChangeSet,
648667
filterTextboxRef,
649668
stickyColumns,
669+
tableMinHeight,
650670
651671
// Methods
652672
handleSelectAllToggle,
@@ -770,4 +790,13 @@
770790
min-height: 0;
771791
}
772792
793+
// Vertically center KCircularLoader within the table
794+
/deep/ .k-table-wrapper > p {
795+
position: absolute;
796+
top: 50%;
797+
left: 50%;
798+
margin: 0;
799+
transform: translate(-50%, -50%);
800+
}
801+
773802
</style>

0 commit comments

Comments
 (0)