-
-
Notifications
You must be signed in to change notification settings - Fork 50.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
当Form组件设置为disabled
时,FormItem中的Upload仍能上传文件
#36554
Comments
借楼回复一下我的观点,估计是因为周末的原因。维护人员没注意 issue。 至于你说的无法获取表单禁用状态,大概看了一下官方其他 antd 组件都是通过 我写了一个 codesandbox demo,不知道是否符合你的需求。 import { Upload } from "antd";
import DisabledContext from "antd/es/config-provider/DisabledContext";
import { UploadOutlined } from "@ant-design/icons";
const CustomUpload = (props) => {
const disabled = React.useContext(DisabledContext);
return (
<Upload disabled={disabled} {...props}>
<UploadOutlined />
</Upload>
);
}; 使用 import { Form } from "antd";
import CustomUpload from "./CustomUpload";
export default function App() {
const uploadProps = {
name: "file",
listType: "picture-card",
action: "https://www.mocky.io/v2/5cc8019d300000980a055e76"
};
return (
<div className="App">
<Form disabled>
<Form.Item label="custom_upload">
<CustomUpload {...uploadProps} />
</Form.Item>
</Form>
</div>
);
} |
Hello @simonNeo. We totally like your proposal/feedback, welcome to send us a Pull Request for it. Please send your Pull Request to proper branch (feature branch for the new feature, master for bugfix and other changes), fill the Pull Request Template here, provide changelog/TypeScript/documentation/test cases if needed and make sure CI passed, we will review it soon. We appreciate your effort in advance and looking forward to your contribution! 你好 @simonNeo,我们完全同意你的提议/反馈,欢迎直接在此仓库 创建一个 Pull Request 来解决这个问题。请将 Pull Request 发到正确的分支(新特性发到 feature 分支,其他发到 master 分支),务必填写 Pull Request 内的预设模板,提供改动所需相应的 changelog、TypeScript 定义、测试用例、文档等,并确保 CI 通过,我们会尽快进行 Review,提前感谢和期待您的贡献。 |
@Wxh16144 谢谢回复,最近业务比较忙,不然也不会当伸手党LOL。我看已经有大佬修复这个问题了,也谢谢官方大佬。 |
Reproduction link
Steps to reproduce
listType
设置为picture-card
What is expected?
点击后不响应点击事件
What is actually happening?
点击后唤起了系统文件选择,并且选择文件后仍能触发上传。
不知道是不是因为标题的原因,发布了之后没有回复,重新发一遍。如果重复还请关闭。
场景: 业务数据状态是动态的,当数据为只读时不允许更新表单里面的数据。
一些想法:手动将Upload设置为
disabled
可以实现不允许选择文件,但是无法获取表单当前是否禁用。也尝试了用ant Button来包裹上传图标,但是listType为picture-card时,children基本无法填充满整个区域,点card外圈仍能触发文件选择和上传。The text was updated successfully, but these errors were encountered: