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: drawer option update sync #554

Merged
merged 1 commit into from
Apr 25, 2024
Merged

Conversation

ccuuu
Copy link

@ccuuu ccuuu commented Mar 26, 2024

修复重复打开抽屉options不会更新的问题

Copy link

changeset-bot bot commented Mar 26, 2024

⚠️ No Changeset found

Latest commit: 2f832d4

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@fengtianze
Copy link
Collaborator

没看明白这什么改法,两者在都是第一次open的情况下是等价的?

@ccuuu
Copy link
Author

ccuuu commented Apr 9, 2024

没看明白这什么改法,两者在都是第一次open的情况下是等价的?

第一次open没问题,存在问题的是后续再次open抽屉,且options有变更时,变更不会生效。
原逻辑中,drawerInternalComponentRef.instance.options的赋值逻辑在 if(this.drawerInternalComponentRef) return 的判断之后,导致了除了第一次打开抽屉,其他情况下 options 的变更都不会生效。
新的改动将 drawerInternalComponentRef.instance.options 赋值逻辑提前了,无论是否存在 this.drawerInternalComponentRef 都不影响 options 赋值更新

@fengtianze
Copy link
Collaborator

没看明白这什么改法,两者在都是第一次open的情况下是等价的?

第一次open没问题,存在问题的是后续再次open抽屉,且options有变更时,变更不会生效。 原逻辑中,drawerInternalComponentRef.instance.options的赋值逻辑在 if(this.drawerInternalComponentRef) return 的判断之后,导致了除了第一次打开抽屉,其他情况下 options 的变更都不会生效。 新的改动将 drawerInternalComponentRef.instance.options 赋值逻辑提前了,无论是否存在 this.drawerInternalComponentRef 都不影响 options 赋值更新

同一个drawerInternalComponentRef实例重复attach时会完整的重新走组件生命周期?

@ccuuu
Copy link
Author

ccuuu commented Apr 10, 2024

没看明白这什么改法,两者在都是第一次open的情况下是等价的?

第一次open没问题,存在问题的是后续再次open抽屉,且options有变更时,变更不会生效。 原逻辑中,drawerInternalComponentRef.instance.options的赋值逻辑在 if(this.drawerInternalComponentRef) return 的判断之后,导致了除了第一次打开抽屉,其他情况下 options 的变更都不会生效。 新的改动将 drawerInternalComponentRef.instance.options 赋值逻辑提前了,无论是否存在 this.drawerInternalComponentRef 都不影响 options 赋值更新

同一个drawerInternalComponentRef实例重复attach时会完整的重新走组件生命周期?

更新时不会再次 attach ,而是复用第一次 attach 的 drawerInternalComponentRef(this.drawerInternalComponentRef),并更新 options。
企业微信截图_f8d1dca1-ad27-4b61-b2f5-3abdcdca2613

因此组件生命周期不会重走一遍,只是会更新 options

@fengtianze
Copy link
Collaborator

internal component 在ngAfterViewInit生命周期里读取了options并执行了一些逻辑,update时只更新options所有配置都能按预期生效?

internal component最好暴露个method来更新options

@fengtianze
Copy link
Collaborator

为什么不直接改成每次都初始化新的internal component?

@ccuuu
Copy link
Author

ccuuu commented Apr 10, 2024

internal component 在ngAfterViewInit生命周期里读取了options并执行了一些逻辑,update时只更新options所有配置都能按预期生效?

internal component最好暴露个method来更新options

1

@ccuuu
Copy link
Author

ccuuu commented Apr 11, 2024

为什么不直接改成每次都初始化新的internal component?

可配置,options.disposeWhenHide 为 true 的话就会在每次打开时初始化

@ccuuu ccuuu force-pushed the fix/drawer-options-update branch from 7ee21be to 3d21193 Compare April 11, 2024 02:27
fengtianze
fengtianze previously approved these changes Apr 25, 2024
@fengtianze fengtianze merged commit 11caa9d into master Apr 25, 2024
8 checks passed
@fengtianze fengtianze deleted the fix/drawer-options-update branch April 25, 2024 07:22
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