Skip to content

Commit

Permalink
fix: buttonGroupSelect传入buttons时没有选中态
Browse files Browse the repository at this point in the history
  • Loading branch information
qkiroc committed Aug 24, 2023
1 parent 145a4ac commit 6ef8ed2
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions packages/amis/src/renderers/Form/ButtonGroupSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export default class ButtonGroupControl extends React.Component<

if (options && options.length) {
body = options.map((option, key) => {
const active = !!~selectedOptions.indexOf(option);
const active = !!~selectedOptions?.indexOf(option);
const optionBadge = this.getBadgeConfig(badge, option);

return render(
Expand Down Expand Up @@ -150,7 +150,6 @@ export default class ButtonGroupControl extends React.Component<
} else if (Array.isArray(buttons)) {
body = buttons.map((button, key) => {
const buttonBadge = this.getBadgeConfig(badge, button);
const active = !!~selectedOptions.indexOf(button);
return render(
`button/${key}`,
{
Expand All @@ -164,11 +163,7 @@ export default class ButtonGroupControl extends React.Component<
},
{
key,
className: cx(
button.className,
btnClassName,
active && 'ButtonGroup-button--active'
)
className: cx(button.className, btnClassName)
}
);
});
Expand Down

0 comments on commit 6ef8ed2

Please sign in to comment.