admin管理员组文章数量:1421921
The Popconfirm-modal in Ant Design has the Confirm ("Yes"-)-Button preselected when the modal-window opens.
Source-code for the modal:
import { Popconfirm, message } from 'antd';
function confirm(e) {
console.log(e);
message.success('Click on Yes');
}
function cancel(e) {
console.log(e);
message.error('Click on No');
}
ReactDOM.render(
<Popconfirm title="Are you sure delete this task?" onConfirm={confirm} onCancel={cancel} okText="Yes" cancelText="No">
<a href="#">Delete</a>
</Popconfirm>
, mountNode);
Documentation and live-demo here: Ant Design Documentation
Is there a way to change the described default-behaviour?
Precisely: Is there a way to define the Cancel (respectively "No"-)-Button as preselected when the Modal appears?
The Popconfirm-modal in Ant Design has the Confirm ("Yes"-)-Button preselected when the modal-window opens.
Source-code for the modal:
import { Popconfirm, message } from 'antd';
function confirm(e) {
console.log(e);
message.success('Click on Yes');
}
function cancel(e) {
console.log(e);
message.error('Click on No');
}
ReactDOM.render(
<Popconfirm title="Are you sure delete this task?" onConfirm={confirm} onCancel={cancel} okText="Yes" cancelText="No">
<a href="#">Delete</a>
</Popconfirm>
, mountNode);
Documentation and live-demo here: Ant Design Documentation
Is there a way to change the described default-behaviour?
Precisely: Is there a way to define the Cancel (respectively "No"-)-Button as preselected when the Modal appears?
Share Improve this question asked Feb 20, 2018 at 12:59 cluster1cluster1 5,8587 gold badges38 silver badges59 bronze badges 2- What do you mean with "preselected" ? it's preselected to none. do you want to invert the button with primary (blue) color to the "cancel" button? – Yichz Commented Feb 21, 2018 at 23:25
- @Kossel Yes. Exactly. I like to have the cancel-button (as the more harmless action) to be blue. And the harmful action NOT highlighted when the window appears. – cluster1 Commented Feb 22, 2018 at 10:37
1 Answer
Reset to default 3You can only get half-way I am afraid.
If you provide an okType="default"
property, the "Yes" button will no longer have type="primary"
, and thus look just like the "No" button.
However there is no support for a corresponding cancelType
property, which means you are not able to make the "No" button blue.
This does feel like a slightly limping API, so you might have success filing a PR implementing cancelType
. Should be a very simple 3-line patch against https://github./ant-design/ant-design/blob/master/ponents/popconfirm/index.tsx
本文标签: javascriptAnt Design PopconfirmChanging the preselected button to CancelStack Overflow
版权声明:本文标题:javascript - Ant Design Popconfirm - Changing the preselected button to Cancel - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745361722a2655326.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论