Skip to content

Commit 23cf9da

Browse files
committed
IBX-10895: Fixed RadioButton issues
1 parent 1bd2253 commit 23cf9da

File tree

14 files changed

+61
-19
lines changed

14 files changed

+61
-19
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,30 @@
11
@use 'functions' as *;
2+
@use 'variables' as *;
23

34
.ids-choice-input-field {
5+
--ids-input-hover-border-color: var(--ids-input-hover-color, #{$color-primary-80});
6+
--ids-input-hover-text-color: var(--ids-input-hover-color, #{$color-primary-80});
7+
48
display: flex;
59
align-items: center;
610
gap: calculateRem(8px);
11+
12+
&--disabled {
13+
.ids-choice-input-label {
14+
color: var(--ids-input-disabled-text-color, #{$color-neutral-150});
15+
pointer-events: none;
16+
}
17+
}
18+
19+
&--error {
20+
.ids-choice-input-label {
21+
color: var(--ids-input-error-text-color, #{$color-error-80});
22+
}
23+
}
24+
25+
&:hover:not(&--disabled) {
26+
.ids-choice-input-label {
27+
color: var(--ids-input-hover-text-color);
28+
}
29+
}
730
}

packages/assets/src/scss/mixins/_inputs.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
pointer-events: none;
3030
}
3131

32-
&:hover {
32+
&:hover:not(&--disabled) {
3333
border-color: var(--ids-input-hover-border-color, #{$color-primary-80});
3434
}
3535

packages/components/src/components/RadioButton/RadioButtonField/RadioButtonField.stories.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { Meta, StoryObj } from '@storybook/react';
22
import { action } from 'storybook/actions';
33

4+
import { FormDecorator } from '@ids-sb-decorators/FormDecorator';
45
import { RadioButtonFieldStateful } from './';
56

67
const meta: Meta<typeof RadioButtonFieldStateful> = {
@@ -16,6 +17,7 @@ const meta: Meta<typeof RadioButtonFieldStateful> = {
1617
onFocus: action('on-focus'),
1718
onInput: action('on-input'),
1819
},
20+
decorators: [FormDecorator],
1921
};
2022

2123
export default meta;

packages/components/src/components/RadioButton/RadioButtonField/RadioButtonField.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import { RadioButtonFieldProps } from './RadioButtonField.types';
99

1010
export const RadioButtonField = ({
1111
className = '',
12-
label,
1312
inputWrapperClassName = '',
13+
label,
1414
labelClassName = '',
1515
...inputProps
1616
}: RadioButtonFieldProps) => {
@@ -25,6 +25,8 @@ export const RadioButtonField = ({
2525
return (
2626
<BaseChoiceInputField
2727
className={fieldClassName}
28+
disabled={inputProps.disabled}
29+
error={inputProps.error}
2830
id={inputProps.id}
2931
inputWrapperClassName={inputWrapperClassName}
3032
labelClassName={labelClassName}

packages/components/src/components/RadioButton/RadioButtonInput/RadioButtonInput.stories.tsx

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import React from 'react';
2-
31
import type { Meta, StoryObj } from '@storybook/react';
42
import { action } from 'storybook/actions';
53

4+
import { FormDecorator } from '@ids-sb-decorators/FormDecorator';
65
import { RadioButtonInputStateful } from '.';
76

87
const meta: Meta<typeof RadioButtonInputStateful> = {
@@ -16,15 +15,7 @@ const meta: Meta<typeof RadioButtonInputStateful> = {
1615
onFocus: action('on-focus'),
1716
onInput: action('on-input'),
1817
},
19-
decorators: [
20-
(Story) => {
21-
return (
22-
<form name="default-form">
23-
<Story />
24-
</form>
25-
);
26-
},
27-
],
18+
decorators: [FormDecorator],
2819
};
2920

3021
export default meta;

packages/components/src/components/RadioButton/RadioButtonsListField/RadioButtonsListField.stories.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { Meta, StoryObj } from '@storybook/react';
22
import { action } from 'storybook/actions';
33

44
import { RadioButtonsListFieldDirection, RadioButtonsListFieldStateful } from '.';
5+
import { FormDecorator } from '@ids-sb-decorators/FormDecorator';
56

67
const meta: Meta<typeof RadioButtonsListFieldStateful> = {
78
component: RadioButtonsListFieldStateful,
@@ -18,6 +19,7 @@ const meta: Meta<typeof RadioButtonsListFieldStateful> = {
1819
{ id: 'item3', label: 'Item 3', value: 'item3' },
1920
],
2021
},
22+
decorators: [FormDecorator],
2123
};
2224

2325
export default meta;

packages/components/src/hoc/withStateChecked.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { FC, useState } from 'react';
1+
import React, { FC, useEffect, useState } from 'react';
22

33
type OnChangeFn = (checked: boolean, ...args: any[]) => any; // eslint-disable-line @typescript-eslint/no-explicit-any
44

@@ -22,6 +22,10 @@ export const withStateChecked = <T extends object>(WrappedComponent: FC<any>) =>
2222
}
2323
};
2424

25+
useEffect(() => {
26+
setComponentChecked(checked);
27+
}, [checked]);
28+
2529
return <WrappedComponent {...restProps} checked={componentChecked} onChange={handleChange} />;
2630
};
2731

packages/components/src/hoc/withStateValue.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { FC, useState } from 'react';
1+
import React, { FC, useEffect, useState } from 'react';
22

33
type OnChangeFn<T> = (value: T, ...args: any[]) => any; // eslint-disable-line @typescript-eslint/no-explicit-any
44

@@ -22,6 +22,10 @@ export const withStateValue = <Props, ValueType>(WrappedComponent: FC<any>) => {
2222
}
2323
};
2424

25+
useEffect(() => {
26+
setComponentValue(value);
27+
}, [value]);
28+
2529
return <WrappedComponent {...restProps} onChange={handleChange} value={componentValue} />;
2630
};
2731

packages/components/src/partials/BaseChoiceInput/BaseChoiceInput.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export const BaseChoiceInput = ({
2020
id = undefined,
2121
inputClassName = '',
2222
ref,
23-
required = false,
2423
title = '',
2524
value = '',
2625
}: BaseChoiceInputProps) => {
@@ -58,7 +57,6 @@ export const BaseChoiceInput = ({
5857
id={id}
5958
name={name}
6059
ref={ref}
61-
required={required}
6260
title={title}
6361
type={type}
6462
value={value}

packages/components/src/partials/BaseChoiceInput/BaseChoiceInput.types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,5 @@ export interface BaseChoiceInputProps extends BaseComponentAriaAttributes {
2020
id?: string;
2121
inputClassName?: string;
2222
ref?: Ref<HTMLInputElement>;
23-
required?: boolean;
2423
value?: string;
2524
}

0 commit comments

Comments
 (0)