Skip to content

A self-hosted media server and file management system

fix(code-smells): security hotspot using math.random

aminnausin2b034350380e
diff --git a/resources/js/components/cedar-ui/input/LabelledTextInput.vue b/resources/js/components/cedar-ui/input/LabelledTextInput.vue
index cce51c70..e0834205 100644
--- a/resources/js/components/cedar-ui/input/LabelledTextInput.vue
+++ b/resources/js/components/cedar-ui/input/LabelledTextInput.vue
@@ -1,12 +1,14 @@
<script setup lang="ts">
import type { LabelledTextInputProps } from '@aminnausin/cedar-ui';
+import { computed, useId } from 'vue';
import { FormLabel } from '../form';
import { TextInput } from '.';
-withDefaults(defineProps<LabelledTextInputProps>(), {
- id: 'text-input-labelled-' + Math.floor(Math.random() * 10000),
-});
+const props = defineProps<LabelledTextInputProps>();
+
+const autoId = useId();
+const id = computed(() => props.id ?? `text-input-labelled-${autoId}`);
const model = defineModel();
</script>