ant-design / ant-design/pro-components

🐛[BUG] ProeditProtable期望select切换为某个值,展示input框提供输入,实例输入input后值被莫名拦截赋值select

Open
#8,706 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
4.8k
Forks
1.4k
Avg merge
10h 44m
Merged PRs (30d)
3

Description

问题已解决,写出来当个思路给后来人看看,有权限大佬看到翻转下状态
需求:当 select选中为'3'时,展示input框,输入数据保存
问题:切换为input后,输入除了‘3’,任何值都会将状态赋值给constant.comPanyType,导致input框消失,一直没找到原因
解决方案: input内的onChange事件阻止冒泡e.stopPopagition即可解决,并利用setRowData将值保存到inputVal

const options = [
{ value: '1', label: '股份有限公司' },
{ value: '2', label: '私有公司' },
{ value: '3', label: '其他' }
]

const handleSelect = (val: any, constant: any) => {
ref?.current?.setRowData(constant.recordKey, { comPanyType: val })
}

const columns = [
{
title: '公司类型',
dataIndex: 'companyType',
width: '15%',
renderFormItem: (_: any, constant: any) => {
const {
record: { companyType, inputVal = '' } // 本身没有inputVal,期望用来存input的数据
} = constant
return (


{
handleSelect(val, constant)
}}
showSearch={false}
/>
{companyType === '3' && }

)
}
}
]

Contributor guide

Open the contributing guide

Research direction

No repository file or test is named; start by reviewing the inline ProeditProtable example and reproducing the select-to-input behavior. The issue reports that the problem was already resolved with input event handling and row data updates, so confirm whether a repository change is still needed before proceeding.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.