如何在保存时关闭碳模态

How to close carbon Modal on save

我正在使用来自 'carbon-components-react'

的 ModalWrapper

点击保存后,它不会关闭模式。 如何强制关闭?

查看示例 codesandbox https://codesandbox.io/s/carbon-components-react-forked-n09un?file=/src/index.js

使用 ModalWrapper,您必须将 shouldCloseAfterSubmit 添加到您的 ModalWrapper 并在您的 handleModalSave 中添加 return true 函数

// HandleModalSave
const handleModalSave = (data, ssdf) => {
  return true;
};

// ModalWrapper
<ModalWrapper
  buttonTriggerText="Save"
  modalHeading="Save Table"
  handleSubmit={handleModalSave}
  primaryButtonText={primaryButtonText}
  shouldCloseAfterSubmit
>