Skip to content
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

fix: form field validate not check mount status #2206

Merged
merged 2 commits into from
Apr 26, 2024

Conversation

sylingd
Copy link
Contributor

@sylingd sylingd commented Apr 25, 2024

中文模板 / Chinese Template

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Test Case
  • TypeScript definition update
  • Document improve
  • CI/CD improve
  • Branch sync
  • Other, please describe:

PR description

Field 校验完成后,没有验证 Field 是不是已经处于被卸载的状态;
因此在校验开始 -> 卸载Field -> 校验结束这个过程中,校验结果(假设为失败)仍然会写入到 FormState;
Field 重新挂载后,再触发(不管是通过API调用还是事件触发)Field 的校验,因为该 Field 自身的 state 中是校验成功状态,因此不会将新的校验结果写入到 FormState,导致 FormState 中仍然保留失败的状态。

After the Field verification is completed, it is not verified whether the Field has been unmounted;
Therefore, during the process of verification starting -> unmount Field -> verification ending, the verification result (assumed to be a failure) will still be written to FormState;
After the Field is remounted, trigger verification again (whether triggered by an API call or an event). Because the Field's own state is a verification success state, the new verification results will not be written to the FormState. Causes the failed state to remain in FormState.

Changelog

🇨🇳 Chinese

  • Fix: field卸载后,异步校验的结果仍然会写至formState,导致form校验失败

🇺🇸 English

  • Fix: after field unmounted, the asynchronous verification result will still be written to FormState, and causing Form verification fail.

Checklist

  • Test or no need
  • Document or no need
  • Changelog or no need

Other

  • Skip Changelog

Additional information

Copy link

codesandbox-ci bot commented Apr 25, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 2fb0c42:

Sandbox Source
pr-story Configuration

@pointhalo pointhalo merged commit 53c26e6 into DouyinFE:release Apr 26, 2024
5 of 6 checks passed
@pointhalo
Copy link
Collaborator

该修改导致了 #2251 #2210 问题

在 StrictMode下组件会 挂载 -> 卸载 -> 挂载,
isUnmounted 若在 useIsomorphicEffect 挂载时未显式恢复为 false,会导致严格模式下,校验无法被正确返回。

计划今天在v2.59.0 追加一个补丁:#2211 解决

@sylingd sylingd deleted the fix-field-validate branch May 24, 2024 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants