Skip to content

affix has rendering problems when the keep-alive component is reactivated, and scroll must be triggered once to resume #4876

@ydq

Description

@ydq
  • I have searched the issues of this repository and believe that this is not a duplicate.

Version

3.0.0-alpha.11

Environment

vue 3.2.21

Reproduction link

https://github.com/vueComponent/ant-design-vue

Steps to reproduce

<transition appear>
    <keep-alive>

        <!-- 自定义组件里面包含有 affix -->

            <a-row>
                <a-col :span="12">
                    <a-affix>
                        !!里面有比如 <a-form> / <a-input> 或者 <a-anchor> 时 组件重新渲染的时候 渲染的样式奇奇怪怪的
                    </a-affix>
                </a-col>
                <a-col :span="12">bar</a-col>
            </a-row>

        <!-- 上面是自定义组件里面的伪代码 -->

    </keep-alive>
</transition>

当组件重新激活的时候 affix 的渲染有问题

目前临时的解决方案只能强制在 onActivated 里面触发一下 scroll

//临时解决方案 但如果恰好滚动条就在那个位置的话也没办法了
onActivated(() => window.scrollTo({ top: 1, behavior: "smooth" }));

而且如果有动画的话非得在动画结束后才能触发scroll,导致在动画执行期间页面看起来也怪怪的

实在是想不到更好的解决办法了,不知道能否修复

What is expected?

组件被正确的渲染

What is actually happening?

当组件重新激活的时候 affix 的渲染有问题

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions