Skip to content

Commit

Permalink
fix(fields): prevent onChange event on readOnly mode
Browse files Browse the repository at this point in the history
  • Loading branch information
claire2212 committed Sep 25, 2023
1 parent 7b903cc commit 73ebb17
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/fields/MultiRadio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export function MultiRadio<OptionValue extends OptionValueType = string>({
[onChange]
)

useFieldUndefineEffect(isUndefinedWhenDisabled && disabled, onChange)
useFieldUndefineEffect(isUndefinedWhenDisabled && disabled && !isReadOnly, onChange)

return (
<Fieldset
Expand Down
4 changes: 3 additions & 1 deletion stories/fields/MultiRadio.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { generateStoryDecorator } from '../../.storybook/components/StoryDecorat
import { MultiRadio, useFieldControl } from '../../src'

import type { MultiRadioProps } from '../../src'
import type { Meta } from '@storybook/react'

const args: MultiRadioProps = {
disabled: false,
Expand All @@ -24,7 +25,7 @@ const args: MultiRadioProps = {
value: undefined
}

export default {
const meta: Meta<MultiRadioProps> = {
title: 'Fields/MultiRadio',
component: MultiRadio,

Expand All @@ -43,6 +44,7 @@ export default {
})
]
}
export default meta

export function _MultiRadio(props: MultiRadioProps) {
const [outputValue, setOutputValue] = useState<string | undefined | '∅'>('∅')
Expand Down

0 comments on commit 73ebb17

Please sign in to comment.