Skip to content

Commit 3053388

Browse files
authored
Unique id for MultiState checkbox (primefaces#8473)
1 parent aa0b886 commit 3053388

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

components/lib/multistatecheckbox/MultiStateCheckbox.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Checkbox } from '../checkbox/Checkbox';
44
import { useHandleStyle } from '../componentbase/ComponentBase';
55
import { useMergeProps, useMountEffect } from '../hooks/Hooks';
66
import { Tooltip } from '../tooltip/Tooltip';
7-
import { classNames, DomHandler, IconUtils, ObjectUtils } from '../utils/Utils';
7+
import { classNames, DomHandler, IconUtils, ObjectUtils, UniqueComponentId } from '../utils/Utils';
88
import { MultiStateCheckboxBase } from './MultiStateCheckboxBase';
99

1010
export const MultiStateCheckbox = React.memo(
@@ -167,9 +167,12 @@ export const MultiStateCheckbox = React.memo(
167167
ptm('root')
168168
);
169169

170+
const inputId = React.useMemo(() => props.id || UniqueComponentId(), [props.id]);
171+
170172
const checkboxProps = mergeProps(
171173
{
172-
id: props.id + '_checkbox',
174+
id: inputId + '_checkbox',
175+
inputId: props.inputId || inputId + '_multistatecheckbox',
173176
className: cx('checkbox'),
174177
style: sx('checkbox', { selectedOption }),
175178
tabIndex: props.tabIndex,

0 commit comments

Comments
 (0)