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 updateSchema后执行setProps导致schemaRef被重置的问题 #3354

Merged
merged 1 commit into from
Nov 28, 2023

Conversation

hls-1992
Copy link

General

✏️ Mark the necessary items without changing the structure of the PR template.

  • Pull request template structure not broken

Type

ℹ️ What types of changes does your code introduce?

👉 Put an x in the boxes that apply

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist

ℹ️ Check all checkboxes - this will indicate that you have done everything in accordance with the rules in CONTRIBUTING.

👉 Put an x in the boxes that apply.

  • My code follows the style guidelines of this project
  • Is the code format correct
  • Is the git submission information standard?
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

描述 Bug

在BasicForm.vue文件中有如下源码
image
image
当我们先使用updateSchema对schemas进行修改
然后使用setProps更新from的props
此时由于getProps来自props的深拷贝,props.schemas的数组引用发生变化,图中监听器必然触发,导致schemaRef被重置,
出现问题

复现 Bug

  1. (https://vben.vvbin.cn/#/comp/form/useForm)以此页面为例
  2. 我们可以移除字段4的选项,然后在onMounted中使用updateSchema为其传入options
  3. 然后我们调用setProps修改任意formprops,我们会发现字段4没有选项
  4. 移除setProps,选项出现

@hls-1992
Copy link
Author

这样修改可以规避上述错误,且不会有其他不利影响

@wangjue666 wangjue666 merged commit b0e8154 into vbenjs:main Nov 28, 2023
2 checks passed
@wangjue666
Copy link
Collaborator

这样修改可以规避上述错误,且不会有其他不利影响

Thanks 👍

@github-actions github-actions bot locked and limited conversation to collaborators Aug 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants