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
feat: Modal hooks confirm function support await #43470
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Run & review this pull request in StackBlitz Codeflow. |
size-limit report 📦
|
li-jia-nan
approved these changes
Jul 10, 2023
MadCcc
approved these changes
Jul 11, 2023
afc163
reviewed
Jul 11, 2023
|
||
```tsx | ||
//点击 `onOk` 时返回 `true`,点击 `onCancel` 时返回 `false` | ||
const confirmed = await modal.confirm({ ... }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
声明一下版本?
Wxh16144
pushed a commit
to Wxh16144-forks/ant-design
that referenced
this pull request
Jul 12, 2023
* docs: move demo to useModal * docs: reorder * chore: update ts def * test: test case * chore: fix compile
crazyair
reviewed
Aug 7, 2023
then<T>(resolve: (confirmed: boolean) => T, reject: VoidFunction): Promise<T>; | ||
}; | ||
|
||
export type HookAPI = Omit<Record<keyof ModalStaticFunctions, ModalFuncWithPromise>, 'warn'>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UseModalResult?导出去名字规范些
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
[中文版模板 / Chinese template]
🤔 This is a ...
🔗 Related issue link
ref #43295
💡 Background and solution
📝 Changelog
await
call.await
调用。☑️ Self-Check before Merge
🚀 Summary
🤖 Generated by Copilot at e7e0285
This pull request enhances the modal component and its hooks method, by adding new props and features. It allows the modal to optionally suppress error messages, return a promise with the user's choice, and customize the close behavior. It also updates the demo code, the tests, and the documentation for the modal component in both English and Chinese. It mainly affects the files
components/modal/*
,components/_util/ActionButton.tsx
, andcomponents/modal/demo/hooks.md
.🔍 Walkthrough
🤖 Generated by Copilot at e7e0285
isSilent
prop toActionButton
andConfirmDialog
components to control error throwing behavior (link, link, link, link, link, link, link)onClose
prop toConfirmDialog
andHookModal
components to supportawait
operation for hooks method of modal (link, link, link, link, link, link, link)useModal
hook to return modal functions withthen
field that returns a promise that resolves with confirmed value (link, link, link, link, link, link, link)hooks.tsx
demo code to useasync
andawait
keywords and log confirmed value (link, link, link)hook.test.tsx
file to add test case forawait
operation (link)hooks.md
,index.en-US.md
,index.zh-CN.md
) to explainawait
operation and link to relevant demo codes (link, link, link, link, link, link, link)