From 5e54306fd0bfb023b3775c6cb69670f2757b8849 Mon Sep 17 00:00:00 2001 From: Fesaa <77553571+Fesaa@users.noreply.github.com> Date: Mon, 9 Jun 2025 17:55:18 +0200 Subject: [PATCH] Fix Import section not showing up in settings (#3849) --- .../setting-switch/setting-switch.component.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/UI/Web/src/app/settings/_components/setting-switch/setting-switch.component.ts b/UI/Web/src/app/settings/_components/setting-switch/setting-switch.component.ts index 530fa2ff3..e39b6beee 100644 --- a/UI/Web/src/app/settings/_components/setting-switch/setting-switch.component.ts +++ b/UI/Web/src/app/settings/_components/setting-switch/setting-switch.component.ts @@ -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); + } + }