fix: unify organization settings modal scrolling

main
ttommybot 2026-08-03 22:24:28 +08:00 committed by lyingbug
parent 82ea91f18e
commit 91b2d31cd4
2 changed files with 71 additions and 3 deletions

View File

@ -14,3 +14,22 @@ test('reviewing join requests goes through the store and refreshes modal data',
const refreshCalls = source.match(/await refreshOrganizationAfterReview\(\)/g) ?? []
assert.equal(refreshCalls.length, 2)
})
test('organization settings use one outer content scroller and reset it on navigation', () => {
assert.match(source, /ref="contentWrapperRef" class="content-wrapper"/)
assert.match(source, /class="data-table-shell members-table-shell"/)
assert.match(source, /contentWrapperRef\.value\?\.scrollTo\(\{ top: 0, behavior: 'auto' \}\)/)
assert.match(source, /watch\(\(\) => props\.visible,[\s\S]*?void scrollContentToTop\(\)/)
assert.match(source, /\}, \{ immediate: true \}\)\s*\n\s*watch\(\(\) => props\.orgId/)
assert.match(source, /watch\(\(\) => props\.orgId,[\s\S]*?void scrollContentToTop\(\)/)
assert.match(source, /watch\(currentSection,[\s\S]*?void scrollContentToTop\(\)/)
assert.match(source, /\.members-table-shell\s*\{[\s\S]*?overflow: visible;[\s\S]*?\.t-table__content/)
})
test('organization settings lock and restore background scrolling', () => {
assert.match(source, /document\.body\.style\.overflow = 'hidden'/)
assert.match(source, /document\.body\.style\.overflow = previousBodyOverflow/)
assert.match(source, /onBeforeUnmount\(\(\) => \{\s*unlockBackgroundScroll\(\)/)
assert.match(source, /\.settings-overlay\s*\{[\s\S]*?overscroll-behavior: none;/)
assert.match(source, /\.content-wrapper\s*\{[\s\S]*?overscroll-behavior: contain;/)
})

View File

@ -38,7 +38,7 @@
<!-- 右侧内容区域 -->
<div class="settings-content">
<div class="content-wrapper">
<div ref="contentWrapperRef" class="content-wrapper">
<!-- 组织管理员但空间角色不足,给出只读提示 -->
<div v-if="showTenantRoleHint" class="tenant-role-hint">
<t-icon name="info-circle" size="16px" />
@ -456,7 +456,7 @@
? $t('organization.members.emptySearch', { q: memberSearchQuery })
: $t('organization.noMembers')" />
</div>
<div v-else class="data-table-shell">
<div v-else class="data-table-shell members-table-shell">
<t-table row-key="id" :data="filteredMembers" :columns="memberColumns" size="medium" hover
stripe :loading="membersLoading">
<template #member="{ row }">
@ -818,7 +818,7 @@
</template>
<script setup lang="ts">
import { ref, computed, watch } from 'vue'
import { ref, computed, watch, nextTick, onBeforeUnmount } from 'vue'
import { useRouter } from 'vue-router'
import { MessagePlugin } from 'tdesign-vue-next'
import { useI18n } from 'vue-i18n'
@ -863,6 +863,7 @@ const emit = defineEmits<{
// State
const currentSection = ref('basic')
const contentWrapperRef = ref<HTMLElement | null>(null)
const orgInfo = computed(() => orgStore.currentOrganization)
const members = computed(() => orgStore.currentMembers)
const sharedKnowledgeBases = ref<KnowledgeBaseShare[]>([])
@ -1855,9 +1856,32 @@ const getPermissionTheme = (permission: string) => {
}
}
const scrollContentToTop = async () => {
await nextTick()
contentWrapperRef.value?.scrollTo({ top: 0, behavior: 'auto' })
}
let previousBodyOverflow = ''
let bodyScrollLocked = false
const lockBackgroundScroll = () => {
if (bodyScrollLocked) return
previousBodyOverflow = document.body.style.overflow
document.body.style.overflow = 'hidden'
bodyScrollLocked = true
}
const unlockBackgroundScroll = () => {
if (!bodyScrollLocked) return
document.body.style.overflow = previousBodyOverflow
bodyScrollLocked = false
}
// Watch
watch(() => props.visible, (newVal) => {
if (newVal) {
lockBackgroundScroll()
void scrollContentToTop()
currentSection.value = 'basic'
memberSearchQuery.value = ''
joinRequestSearchQuery.value = ''
@ -1880,15 +1904,28 @@ watch(() => props.visible, (newVal) => {
fetchMembers()
fetchSharedKBs()
}
} else {
unlockBackgroundScroll()
}
}, { immediate: true })
watch(() => props.orgId, () => {
if (props.visible) {
void scrollContentToTop()
}
})
watch(currentSection, (section) => {
void scrollContentToTop()
if (section === 'joinRequests' && props.orgId) {
fetchJoinRequests()
}
})
onBeforeUnmount(() => {
unlockBackgroundScroll()
})
watch(addMemberPopupVisible, (visible) => {
if (!visible) {
resetAddMemberDialog()
@ -1914,6 +1951,7 @@ watch(addMemberPopupVisible, (visible) => {
justify-content: center;
z-index: 2000;
backdrop-filter: blur(4px);
overscroll-behavior: none;
}
.settings-modal {
@ -2082,6 +2120,7 @@ watch(addMemberPopupVisible, (visible) => {
padding: 28px 40px 48px;
box-sizing: border-box;
scroll-padding-bottom: 24px;
overscroll-behavior: contain;
}
.tenant-role-hint {
@ -2832,6 +2871,16 @@ watch(addMemberPopupVisible, (visible) => {
}
}
.members-table-shell {
overflow: visible;
max-height: none;
:deep(.t-table__content) {
overflow: visible !important;
max-height: none !important;
}
}
.permissions-compact {
padding: 8px;