mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 21:41:57 +00:00
refactor(FE-114): use React's useId hook for generating unique checkbox IDs in CheckboxInput
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
'use client';
|
||||
|
||||
import { ChangeEventHandler, FocusEventHandler, ReactNode } from 'react';
|
||||
import { ChangeEventHandler, FocusEventHandler, ReactNode, useId } from 'react';
|
||||
|
||||
import { cn } from '@/lib/helper';
|
||||
import FieldMessage from '@/components/helper/FieldMessage';
|
||||
@@ -101,8 +101,9 @@ const CheckboxInput = ({
|
||||
error: 'checkbox-error',
|
||||
};
|
||||
|
||||
// Generate unique ID for accessibility
|
||||
const checkboxId = `checkbox-${name}-${Math.random().toString(36).substr(2, 9)}`;
|
||||
// Generate unique ID for accessibility using React's useId hook for SSR compatibility
|
||||
const generatedId = useId();
|
||||
const checkboxId = `checkbox-${name}-${generatedId}`;
|
||||
|
||||
// Naked mode - only checkbox, no wrapper structure
|
||||
if (naked) {
|
||||
|
||||
Reference in New Issue
Block a user