Skip to content

Commit 3046905

Browse files
committed
fix: top whitespace and buggy scroll
1 parent cba0544 commit 3046905

File tree

2 files changed

+33
-32
lines changed

2 files changed

+33
-32
lines changed

src/filelist.scss

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
* along with this program. If not, see <http://www.gnu.org/licenses/>.
2020
*/
2121

22-
// Hide the "No files" empty state when securemail content is present
23-
.sendent-hide-empty {
22+
// Hide the entire files-list when there are no real files (only .SECUREMAIL.html)
23+
.sendent-hide-filelist {
2424
display: none !important;
2525
}
2626

@@ -31,6 +31,7 @@
3131
max-width: 100%;
3232
width: 100%;
3333
box-sizing: border-box;
34+
flex-shrink: 0;
3435

3536
.sendent-content__header {
3637
margin: 16px 0 8px;

src/filelist.ts

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class FooterFile {
5858
private source: string,
5959
) {}
6060

61-
public async appendBelowFiles(version: number): Promise<void> {
61+
public async appendBelowFiles(version: number, hasRealFiles: boolean): Promise<void> {
6262
// Skip if a newer render has already been requested
6363
if (version !== renderVersion) return
6464

@@ -72,18 +72,19 @@ class FooterFile {
7272
const container = document.createElement('div')
7373
container.id = CONTENT_ID
7474

75-
// Insert inside the files-list container, after the table, so it's part of
76-
// the natural scroll area and doesn't break the flex layout.
77-
const anchor = document.querySelector('.files-list__table')
78-
|| document.querySelector('.files-filestable')
79-
|| document.querySelector('#filestable')
75+
const filesList = document.querySelector('.files-list')
76+
|| document.querySelector('.files-filestable')?.parentElement
77+
|| document.querySelector('#filestable')?.parentElement
8078

81-
if (!anchor) return
79+
if (!filesList) return
8280

83-
// Hide the "No files" empty state when securemail content is present
84-
hideEmptyState()
81+
// When there are no real files, hide the entire files-list (table headers, empty state, whitespace)
82+
if (!hasRealFiles) {
83+
filesList.classList.add('sendent-hide-filelist')
84+
}
8585

86-
anchor.insertAdjacentElement('afterend', container)
86+
// Insert after .files-list so we're outside its scroll context
87+
filesList.insertAdjacentElement('afterend', container)
8788

8889
// Show loading spinner
8990
const spinner = document.createElement('span')
@@ -163,21 +164,10 @@ class FooterFile {
163164
}
164165

165166
/**
166-
* Hides the Nextcloud "No files" empty state when securemail content is shown.
167-
*/
168-
function hideEmptyState() {
169-
const el = document.querySelector('.files-list__empty')
170-
|| document.querySelector('.files-list .empty-content')
171-
if (el instanceof HTMLElement) {
172-
el.classList.add('sendent-hide-empty')
173-
}
174-
}
175-
176-
/**
177-
* Restores the empty state to its default layout.
167+
* Restores the files-list to its default state.
178168
*/
179-
function restoreEmptyState() {
180-
document.querySelector('.sendent-hide-empty')?.classList.remove('sendent-hide-empty')
169+
function restoreFilesList() {
170+
document.querySelector('.sendent-hide-filelist')?.classList.remove('sendent-hide-filelist')
181171
}
182172

183173
let debounceTimer: ReturnType<typeof setTimeout> | null = null
@@ -199,19 +189,29 @@ function processFileListDebounced(files: any[]) {
199189
*/
200190
function processFileList(files: any[]) {
201191
const version = ++renderVersion
192+
let securemailFile: any = null
193+
let realFileCount = 0
194+
202195
for (const file of files ?? []) {
203196
const basename = file.basename || file.name
204197
if (file.type === 'file' && basename === FOOTER_NAME) {
205-
// Extract directory from full path (Node.dirname or manual extraction)
206-
const dirPath = file.dirname
207-
?? (file.path ? file.path.substring(0, file.path.lastIndexOf('/')) || '/' : '/')
208-
new FooterFile(basename, dirPath, file.source ?? '').appendBelowFiles(version)
209-
return
198+
securemailFile = file
199+
} else if (file.type === 'file') {
200+
realFileCount++
210201
}
211202
}
203+
204+
if (securemailFile) {
205+
const basename = securemailFile.basename || securemailFile.name
206+
const dirPath = securemailFile.dirname
207+
?? (securemailFile.path ? securemailFile.path.substring(0, securemailFile.path.lastIndexOf('/')) || '/' : '/')
208+
new FooterFile(basename, dirPath, securemailFile.source ?? '').appendBelowFiles(version, realFileCount > 0)
209+
return
210+
}
211+
212212
// No securemail file in this directory — clean up stale preview
213213
document.getElementById(CONTENT_ID)?.remove()
214-
restoreEmptyState()
214+
restoreFilesList()
215215
}
216216

217217
/**

0 commit comments

Comments
 (0)