Skip to content

Commit 534842f

Browse files
committed
fix: id prop handling in field components
1 parent caff10a commit 534842f

File tree

12 files changed

+19
-19
lines changed

12 files changed

+19
-19
lines changed

.changeset/radiogroup-id-prop-fix.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
'@cube-dev/ui-kit': patch
33
---
44

5-
Fixed RadioGroup `id` prop to be applied to the root element instead of the field wrapper
5+
Fixed `id` and ARIA attributes duplication where they were incorrectly applied to both the field wrapper and the input element. The `id` prop is now correctly applied only to the element with `qa` and `data-input-type` attributes. The fix was implemented in the `wrapWithField` helper to automatically filter out `id` from `fieldProps` passed to the Field wrapper.
66

src/components/fields/Checkbox/CheckboxGroup.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ function CheckboxGroup(props: WithNullableValue<CubeCheckboxGroupProps>, ref) {
6666
});
6767

6868
let {
69+
id,
6970
isDisabled,
7071
isRequired,
7172
necessityIndicator,
@@ -94,6 +95,7 @@ function CheckboxGroup(props: WithNullableValue<CubeCheckboxGroupProps>, ref) {
9495

9596
let radioGroup = (
9697
<CheckGroupElement
98+
id={id}
9799
styles={inputStyles}
98100
mods={{
99101
horizontal: orientation === 'horizontal',

src/components/fields/ComboBox/ComboBox.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1860,7 +1860,7 @@ export const ComboBox = forwardRef(function ComboBox<T extends object>(
18601860
return wrapWithField<Omit<CubeComboBoxProps<T>, 'children'>>(
18611861
comboBoxField,
18621862
ref,
1863-
mergeProps(finalProps, {}),
1863+
finalProps,
18641864
);
18651865
}) as unknown as (<T>(
18661866
props: CubeComboBoxProps<T> & { ref?: ForwardedRef<HTMLDivElement> },

src/components/fields/DatePicker/DatePicker.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ function DatePicker<T extends DateValue>(
127127
isDisabled={isDisabled}
128128
validationState={validationState}
129129
size={size}
130+
fieldProps={groupProps}
130131
{...focusProps}
131132
suffix={
132133
<DialogTrigger
@@ -172,7 +173,6 @@ function DatePicker<T extends DateValue>(
172173
...props,
173174
styles,
174175
labelProps: mergeProps(props.labelProps, labelProps),
175-
fieldProps: groupProps,
176176
});
177177
}
178178

src/components/fields/DatePicker/DateRangePicker.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ function DateRangePicker<T extends DateValue>(
139139
isDisabled={isDisabled}
140140
validationState={validationState}
141141
size={size}
142+
fieldProps={groupProps}
142143
{...focusProps}
143144
suffix={
144145
<DialogTrigger
@@ -200,7 +201,6 @@ function DateRangePicker<T extends DateValue>(
200201
...props,
201202
styles,
202203
labelProps: mergeProps(props.labelProps, labelProps),
203-
fieldProps: groupProps,
204204
});
205205
}
206206

src/components/fields/DatePicker/DateRangeSeparatedPicker.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ function DateRangeSeparatedPicker<T extends DateValue>(
182182
const component = (
183183
<DatePickerElement
184184
ref={targetRef}
185+
{...groupProps}
185186
styles={props.wrapperStyles}
186187
qa={qa || 'DateRangeSeparatedPicker'}
187188
data-input-type="daterangeseparatedpicker"
@@ -310,7 +311,6 @@ function DateRangeSeparatedPicker<T extends DateValue>(
310311
...props,
311312
styles,
312313
labelProps: mergeProps(props.labelProps, labelProps),
313-
fieldProps: groupProps,
314314
});
315315
}
316316

src/components/fields/FilterListBox/FilterListBox.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -958,7 +958,7 @@ export const FilterListBox = forwardRef(function FilterListBox<
958958
return wrapWithField<Omit<CubeFilterListBoxProps<T>, 'children'>>(
959959
filterListBoxField,
960960
ref,
961-
mergeProps(finalProps, {}),
961+
finalProps,
962962
);
963963
}) as unknown as (<T>(
964964
props: CubeFilterListBoxProps<T> & { ref?: ForwardedRef<HTMLDivElement> },

src/components/fields/FilterPicker/FilterPicker.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -953,14 +953,13 @@ export const FilterPicker = forwardRef(function FilterPicker<T extends object>(
953953

954954
const finalProps = {
955955
...props,
956-
children: undefined,
957956
styles: undefined,
958957
};
959958

960959
return wrapWithField<Omit<CubeFilterPickerProps<T>, 'children' | 'tooltip'>>(
961960
filterPickerField,
962961
ref as any,
963-
mergeProps(finalProps, {}),
962+
finalProps,
964963
);
965964
}) as unknown as (<T>(
966965
props: CubeFilterPickerProps<T> & { ref?: ForwardedRef<HTMLElement> },

src/components/fields/ListBox/ListBox.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,7 @@ export const ListBox = forwardRef(function ListBox<T extends object>(
10341034
return wrapWithField<Omit<CubeListBoxProps<T>, 'children'>>(
10351035
listBoxField,
10361036
ref,
1037-
mergeProps(finalProps, {}),
1037+
finalProps,
10381038
);
10391039
}) as unknown as (<T>(
10401040
props: CubeListBoxProps<T> & { ref?: ForwardedRef<HTMLDivElement> },

src/components/fields/Picker/Picker.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -764,14 +764,10 @@ export const Picker = forwardRef(function Picker<T extends object>(
764764
return wrapWithField<Omit<CubePickerProps<T>, 'children' | 'tooltip'>>(
765765
pickerField,
766766
ref as any,
767-
mergeProps(
768-
{
769-
...props,
770-
children: undefined,
771-
styles: undefined,
772-
},
773-
{},
774-
),
767+
{
768+
...props,
769+
styles: undefined,
770+
},
775771
);
776772
}) as unknown as (<T>(
777773
props: CubePickerProps<T> & { ref?: ForwardedRef<HTMLElement> },

0 commit comments

Comments
 (0)