Skip to content

fix(vc-slick): #6100 - Fix content responsiveness in carousel component slot. #6149

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

Merged
merged 2 commits into from
Dec 15, 2022

Conversation

cn-wang
Copy link
Contributor

@cn-wang cn-wang commented Dec 9, 2022

首先,感谢你的贡献! 😄

新特性请提交至 feature 分支,其余可提交至 master 分支。在一个维护者审核通过后合并。请确保填写以下 pull request 的信息,谢谢!~

[English Template / 英文模板]

这个变动的性质是

  • 新特性提交
  • 日常 bug 修复
  • 站点、文档改进
  • 组件样式改进
  • TypeScript 定义更新
  • 重构
  • 代码风格优化
  • 分支合并
  • 其他改动(是关于什么的改动?)

需求背景

fix issue #6100

实现方案和 API(非新功能可选)

分析:该问题的原因是 vue 中的 cloneVNode 方法在 clone 时未对 children 进行深度 clone;导致同一个 vnode 生成了两份 dom;从而导致该了问题。如下图所示:

image

解决方案:在原来的 cloneElement 基础上做了一层封装,对 vnode 做深度 clone。另因 _util/vnode.ts 的 cloneElement 方法存在大面积的使用,故将实现放在了 vc-slick/utils/innerSliderUtils.js 中

思考是否可以在 vue 中实现,是不是 vue 的 bug,有待进一步了解。

对用户的影响和可能的风险(非新功能可选)

Changelog 描述(非新功能可选)

  1. fix(vc-slick): Fix content responsiveness in carousel component slot. Why can't the content in the slots of the carousel component be responsive? #6100
  2. 修复轮播组件插槽中的内容响应。Why can't the content in the slots of the carousel component be responsive? #6100

请求合并前的自查清单

  • 文档已补充或无须补充
  • 代码演示已提供或无须提供
  • TypeScript 定义已补充或无须补充
  • Changelog 已提供或无须提供

后续计划(非新功能可选)

如果这个提交后面还有相关的其他提交和跟进信息,可以写在这里。

@tangjinzhou
Copy link
Member

可以直接在 util 里面加一个 deepCloneVNode

如下是 vue 源码中的,不过没有 export,供参考

function deepCloneVNode(vnode) {
    const cloned = cloneVNode(vnode);
    if (shared.isArray(vnode.children)) {
        cloned.children = vnode.children.map(deepCloneVNode);
    }
    return cloned;
}

@tangjinzhou tangjinzhou merged commit 8a0c8a8 into vueComponent:main Dec 15, 2022
@AugustEM
Copy link

您好,这个问题的修复版本什么时候发布呢?目前是3.2.15还是有这个问题,很久没有发布新的版本了。 @tangjinzhou

Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 22, 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.

3 participants