Repository navigation
FormTokenField: Validate input before tokenizing on space - #69262
dhruvikpatel18 wants to merge 2 commits into
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. |
|
Thank you, @dhruvikpatel18! Does this also affect tokenization on the Ented key? Both are using Before proceeding with the fix, it would be a good idea to check the "records" and determine the reason for the differences. |
|
Hi, @dhruvikpatel18 Are you still interested in continuing to work on this issue? |
@Mamaduka Thank you for the feedback! You're right - I found that neither |
|
Hey @dhruvikpatel18 , thanks for the contribution! I'm triaging some pull requests which are proposed to close issues which have already been resolved, and it appears that this one was addressed separately in #77181 . I'll close the pull request with the expectation that it may no longer be needed, but please feel free to follow-up (here, in the original issue, or in a new pull request) if there's more work to be done. Thanks! |
Closes #69252
What?
This PR fixes the
FormTokenFieldcomponent to properly validate input before creating tokens when pressing the space key.Why?
Currently, when the
tokenizeOnSpaceprop is enabled, the FormTokenField component creates tokens immediately on space press without checking theexperimentalValidateInputfunction. This can lead to invalid tokens being created, which is inconsistent with the validation behavior when using other methods of token creation (like pressing Enter or comma).How?
Modified the space key handler in the
onKeyDownfunction to:inputHasValidValue()experimentalValidateInputwith the current value