Skip to content

Commit

Permalink
fix: properly adds readonly styles to disabled radio fields (#6176)
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrikKozak committed May 3, 2024
1 parent 6e38cc2 commit 9b7e62d
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 29 deletions.
Expand Up @@ -98,6 +98,7 @@ const RadioGroupInput: React.FC<RadioGroupInputProps> = (props) => {
onChange={readOnly ? undefined : onChange}
option={optionIsObject(option) ? option : { label: option, value: option }}
path={path}
readOnly={readOnly}
/>
</li>
)
Expand Down
Expand Up @@ -70,31 +70,3 @@
}
}
}

.radio-group--read-only {
.radio-input {
cursor: default;

&__label {
color: var(--theme-elevation-800);
}

&--is-selected {
.radio-input__styled-radio {
&:before {
background-color: var(--theme-elevation-800);
}
}
}

&:not(.radio-input--is-selected) {
&:hover {
.radio-input__styled-radio {
&:before {
opacity: 0;
}
}
}
}
}
}
Expand Up @@ -9,7 +9,7 @@ import './index.scss'
const baseClass = 'radio-input'

const RadioInput: React.FC<Props> = (props) => {
const { isSelected, onChange, option, path } = props
const { isSelected, onChange, option, path, readOnly } = props
const { i18n } = useTranslation()

const classes = [baseClass, isSelected && `${baseClass}--is-selected`].filter(Boolean).join(' ')
Expand All @@ -21,6 +21,7 @@ const RadioInput: React.FC<Props> = (props) => {
<div className={classes}>
<input
checked={isSelected}
disabled={readOnly}
id={id}
onChange={() => (typeof onChange === 'function' ? onChange(option.value) : null)}
type="radio"
Expand Down
Expand Up @@ -8,4 +8,5 @@ export type Props = {
value: string
}
path: string
readOnly?: boolean
}
Expand Up @@ -29,6 +29,34 @@
}
}

.radio-group--read-only {
.radio-input {
cursor: default;

&__label {
color: var(--theme-elevation-400);
}

&--is-selected {
.radio-input__styled-radio {
&:before {
background-color: var(--theme-elevation-100);
}
}
}

&:not(.radio-input--is-selected) {
&:hover {
.radio-input__styled-radio {
&:before {
opacity: 0;
}
}
}
}
}
}

html[data-theme='light'] {
.radio-group {
&.error {
Expand Down
Expand Up @@ -55,6 +55,7 @@ const RadioGroup: React.FC<Props> = (props) => {
onChange={readOnly ? undefined : setValue}
options={options}
path={path}
readOnly={readOnly}
required={required}
showError={showError}
style={style}
Expand Down

0 comments on commit 9b7e62d

Please sign in to comment.