ant-design / ant-design

An enterprise-class UI design language and React UI library
https://ant.design
MIT License
90.6k stars 46.73k forks source link

【Modal】期望Modal的onCancel只操控footer的点击事件 推出onClose来控制右上角的关闭icon #48854

Closed Richard-Zhang1019 closed 3 weeks ago

Richard-Zhang1019 commented 3 weeks ago

What problem does this feature solve?

部分场景footer的取消按钮不只是关闭Modal 会有其他的事件 在onCancel绑定事件后右上角的关闭icon也会被绑定这个事件 而期望状态 是右上角依旧为关闭事件 目前是支持不了 需要手动的去自己渲染footer的button

image

What does the proposed API look like?

添加onClose Api来支持右上角的关闭 如果没有单独使用onClose则依旧保持原有逻辑 方便兼容老的逻辑

zombieJ commented 3 weeks ago

直接自定义 footer 就行了:

Demo: 自定义页脚

afc163 commented 3 weeks ago

部分场景footer的取消按钮不只是关闭 Modal 会有其他的事件

  const handleCancel = (e) => {
    console.log(e.currentTarget);
  };