Add async validation support to FormTokenField#71428
Add async validation support to FormTokenField#71428Shekhar0109 wants to merge 1 commit intoWordPress:trunkfrom
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @Shekhar0109! In case you missed it, we'd love to have you join us in our Slack community. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
|
Thanks for the PR! If I understand correctly, #71310 seems to target the components in the cc @WordPress/gutenberg-components @oandregal |
|
Thanks @t-hamano for clarifying! Yes, my intent was to address async validation in FormTokenField as part of the async refinements tracked in #71310. Please let me know if this should be scoped differently. I noticed some failing checks: I’ll update CHANGELOG.md for the components package. I’ll push the fixes shortly 🚀 |
|
Validation support is being implemented in a more centralized way, and support for |
|
Thanks for contributing, @Shekhar0109! It appears that the same task is already in progress, so I think we can close the PR. I think you're a first-time contributor? You're welcome to contribute in whatever way you want, but general advice is to start with the 'Good First Issue' label that is usually more suited for first contributors - https://github.com/WordPress/gutenberg/issues?q=is%3Aissue%20state%3Aopen%20label%3A%22Good%20First%20Issue%22. Don't forget to check the contribution guidelines - https://developer.wordpress.org/block-editor/contributors/code/. Configuring your development environment and following guidelines is important for an open-source project. |
What?
Closes #71310
This PR adds async validation support to the
FormTokenFieldcomponent. It updates the token submission logic to handle both synchronous and asynchronous validation functions. When async validation fails, an error message is shown below the input.Why?
Currently,
FormTokenFieldonly supports synchronous validation. This prevents integration with APIs or other asynchronous validation logic. Supporting async validation allows token input to be verified in real-time against external sources before being added.How?
isValidatingandasyncErrorstate to track validation state.addNewTokento an async function that handles both sync and async validation.<StyledHelp>with a new.components-form-token-field__errorCSS class.Testing Instructions
FormTokenField.Testing Instructions for Keyboard