Fix Import section not showing up in settings (#3849)

This commit is contained in:
Fesaa 2025-06-09 17:55:18 +02:00 committed by GitHub
parent fc4ba4509f
commit 5e54306fd0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -51,7 +51,7 @@ export class SettingSwitchComponent implements AfterContentInit {
const inputElement = element.querySelector('input');
// If no id, generate a random id and assign it to the input
inputElement.id = crypto.randomUUID();
inputElement.id = this.generateId();
if (inputElement && inputElement.id) {
this.labelId = inputElement.id;
@ -62,4 +62,13 @@ export class SettingSwitchComponent implements AfterContentInit {
});
}
private generateId(): string {
if (crypto && crypto.randomUUID) {
return crypto.randomUUID();
}
// Fallback for browsers without crypto.randomUUID (which has happened multiple times in my user base)
return 'id-' + Math.random().toString(36).substr(2, 9) + '-' + Date.now().toString(36);
}
}