Skip to content

Commit 6ef9986

Browse files
authored
fix: styles prop leakage (#912)
1 parent bb390e2 commit 6ef9986

File tree

5 files changed

+18
-4
lines changed

5 files changed

+18
-4
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@cube-dev/ui-kit": patch
3+
---
4+
5+
Fixed `styles` prop leaking to inner elements in `TextInput` and `Switch` components
6+

src/components/fields/NumberInput/NumberInput.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export interface CubeNumberInputProps
2222
}
2323

2424
const StyledTextInputBase = tasty(TextInputBase, {
25-
styles: {
25+
inputStyles: {
2626
textAlign: 'right',
2727
},
2828
});

src/components/fields/Switch/Switch.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,9 @@ function Switch(props: WithNullableSelected<CubeSwitchProps>, ref) {
164164

165165
let styles = extractStyles(props, OUTER_STYLES);
166166

167-
inputStyles = extractStyles(props, BLOCK_STYLES, inputStyles);
167+
inputStyles = extractStyles(props, BLOCK_STYLES, inputStyles, undefined, [
168+
'styles',
169+
]);
168170

169171
let { isFocused, focusProps } = useFocus({ isDisabled }, true);
170172
let { hoverProps, isHovered } = useHover({ isDisabled });

src/components/fields/TextInput/TextInputBase.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,13 @@ function _TextInputBase(props: CubeTextInputBaseProps, ref) {
263263
let styles = extractStyles(otherProps, OUTER_STYLES);
264264
let type = otherProps.type;
265265

266-
inputStyles = extractStyles(otherProps, INPUT_STYLE_PROPS_LIST, inputStyles);
266+
inputStyles = extractStyles(
267+
otherProps,
268+
INPUT_STYLE_PROPS_LIST,
269+
inputStyles,
270+
undefined,
271+
['styles'],
272+
);
267273

268274
let ElementType: 'textarea' | 'input' = multiLine ? 'textarea' : 'input';
269275
let { isFocused, focusProps } = useFocus({ isDisabled });

src/tasty/utils/styles.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ export function extractStyles(
373373
): Styles {
374374
const styles: Styles = {
375375
...defaultStyles,
376-
...props.styles,
376+
...(ignoreList.includes('styles') ? undefined : props.styles),
377377
};
378378

379379
Object.keys(props).forEach((prop) => {

0 commit comments

Comments
 (0)