diff --git a/.changeset/young-candies-appear.md b/.changeset/young-candies-appear.md new file mode 100644 index 0000000000..d7b0436f0e --- /dev/null +++ b/.changeset/young-candies-appear.md @@ -0,0 +1,14 @@ +--- +'@leafygreen-ui/confirmation-modal': patch +'@leafygreen-ui/password-input': patch +'@leafygreen-ui/progress-bar': patch +'@leafygreen-ui/form-field': patch +'@lg-tools/eslint-plugin': patch +'@leafygreen-ui/checkbox': patch +'@leafygreen-ui/select': patch +'@leafygreen-ui/modal': patch +'@leafygreen-ui/lib': patch +'@lg-tools/lint': patch +--- + +Avoid duplicated data-lgid and data-testid diff --git a/packages/checkbox/src/Checkbox/Checkbox.tsx b/packages/checkbox/src/Checkbox/Checkbox.tsx index 30deb9c76b..90a1d3ded7 100644 --- a/packages/checkbox/src/Checkbox/Checkbox.tsx +++ b/packages/checkbox/src/Checkbox/Checkbox.tsx @@ -137,8 +137,8 @@ const Checkbox = React.forwardRef( className={cx(labelStyle, labelHoverStyle[theme], { [disabledLabelStyle]: disabled, })} - data-lgid={lgIds.root} - data-testid={lgIds.root} + data-lgid={lgIds.label} + data-testid={lgIds.label} > {description} diff --git a/packages/checkbox/src/utils/getLgIds.ts b/packages/checkbox/src/utils/getLgIds.ts index 147cc07635..545f19ad49 100644 --- a/packages/checkbox/src/utils/getLgIds.ts +++ b/packages/checkbox/src/utils/getLgIds.ts @@ -5,6 +5,8 @@ export const DEFAULT_LGID_ROOT = 'lg-checkbox'; export const getLgIds = (root: LgIdString = DEFAULT_LGID_ROOT) => { const ids = { root, + label: `${root}-label`, + description: `${root}-description`, } as const; return ids; }; diff --git a/packages/form-field/src/FormField/FormField.tsx b/packages/form-field/src/FormField/FormField.tsx index 5d3ae4a202..82025fc338 100644 --- a/packages/form-field/src/FormField/FormField.tsx +++ b/packages/form-field/src/FormField/FormField.tsx @@ -94,8 +94,8 @@ export const FormField = forwardRef( > {label && (