ant-design/ant-design-mobile

selector组件选中高亮存在因包含关系判断错误问题

Closed this issue · 6 comments

Version of antd-mobile

5.35.0

Operating system and its version

iOS

Browser and its version

No response

Sandbox to reproduce

No response

What happened?

如图所示我选择1000的时候会高亮100和1000,组件并没有设置多项属性
查看源码发现使用的是遍历选项值是否包含在选中值中

 const items = props.options.map(option => {
    const active = (value || []).includes(option[valueName])
    const disabled = option[disabledName] || props.disabled
    const itemCls = classNames(`${classPrefix}-item`, {
      [`${classPrefix}-item-active`]: active && !props.multiple,
      [`${classPrefix}-item-multiple-active`]: active && props.multiple,
      [`${classPrefix}-item-disabled`]: disabled,
    })
})

查看源码位置

WX20240408-093959@2x

Relevant log output

No response

CleanShot2024-04-08at11 02 29@2x
没有复现 demo

@Przeblysk
这里有复现的demo remix框架中运行的,选中demo中的1000或者5000都可以复习

@Przeblysk 这里有复现的demo remix框架中运行的,选中demo中的1000或者5000都可以复习

你demo的外层form去掉没有问题:P

@Przeblysk 我是想要放到 form 表单里面使用的,去掉了 form,就不方便了吧

@Przeblysk 我是想要放到 form 表单里面使用的,去掉了 form,就不方便了吧

你用法不对嘛兄弟 form demo

@Przeblysk 我是想要放到 form 表单里面使用的,去掉了 form,就不方便了吧

你用法不对嘛兄弟 form demo

谢谢,是这里的问题
image