Skip to content

fix: 🐛 修复collapse查看更多模式下,初始状态为展开时,无法收起的问题#1449

Open
ideal-5 wants to merge 1 commit intoMoonofweisheng:masterfrom
ideal-5:fix-collapse
Open

fix: 🐛 修复collapse查看更多模式下,初始状态为展开时,无法收起的问题#1449
ideal-5 wants to merge 1 commit intoMoonofweisheng:masterfrom
ideal-5:fix-collapse

Conversation

@ideal-5
Copy link
Copy Markdown
Contributor

@ideal-5 ideal-5 commented Jan 19, 2026

🤔 这个 PR 的性质是?(至少选择一个)

  • 日常 bug 修复
  • 新特性提交
  • 站点、文档改进
  • 演示代码改进
  • 组件样式/交互改进
  • TypeScript 定义更新
  • CI/CD 改进
  • 包体积优化
  • 性能优化
  • 功能增强
  • 国际化改进
  • 代码重构
  • 代码风格优化
  • 测试用例
  • 分支合并
  • 其他改动(是关于什么的改动?)

🔗 相关 Issue

💡 需求背景和解决方案

1. 复现

<template>
  <wd-collapse viewmore v-model="value4">
    这是一条简单的示例文字。这是一条简单的示例文字。这是一条简单的示例文字。这是一条简单的示例文字。这是一条简单的示例文字。这是一条简单的示例文字。这是一条简单的示例文字。这是一条简单的示例文字。
  </wd-collapse>
</template>

<script lang="ts" setup>
import { ref } from 'vue'
const value4 = ref(true)  // 初始展开状态下无法收起
</script>

2. 解决方案

初始化时不判断 modelValue状态,保证初始展开状态下仍可正常进行收起操作。

☑️ 请求合并前的自查清单

⚠️ 请自检并全部勾选全部选项⚠️

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

Summary by CodeRabbit

发布说明

  • Bug 修复
    • 优化了折叠组件在"查看更多"模式下的内容行数计算逻辑,改进了内容截断行为的准确性。

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link
Copy Markdown

vercel bot commented Jan 19, 2026

@ideal-5 is attempting to deploy a commit to the weisheng's projects Team on Vercel.

A member of the Team first needs to authorize it.

@netlify
Copy link
Copy Markdown

netlify bot commented Jan 19, 2026

Deploy Preview for wot-design-uni ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 16c80e3
🔍 Latest deploy log https://app.netlify.com/projects/wot-design-uni/deploys/696de71612e11e00085c601e
😎 Deploy Preview https://deploy-preview-1449--wot-design-uni.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jan 19, 2026

走查

修改了 wd-collapse 组件中 onBeforeMount 生命周期钩子内 contentLineNum 的初始化逻辑。移除了初始化时对 modelValue 的依赖判断,使得在 viewmore 模式下的内容行数计算仅基于 viewmore 状态和 lineNum 值。

变更

组群 / 文件 变更摘要
wd-collapse 组件逻辑调整
src/uni_modules/wot-design-uni/components/wd-collapse/wd-collapse.vue
简化 contentLineNum 初始化逻辑:从 contentLineNum = viewmore && !modelValue ? lineNum : 0 改为 contentLineNum = viewmore ? lineNum : 0,移除对 modelValue 的条件判断

建议审阅者

  • Moonofweisheng

诗句

🐰 折叠之组件,逻辑更清晰,
移除旧依赖,行数自决定,
展开与收起,变得更灵活,
兔儿拍手称赞,代码焕新颜~

代码审阅工作量估计

🎯 1 (Trivial) | ⏱️ ~3 分钟

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确描述了主要变更内容:修复collapse组件在viewmore模式下初始展开状态时无法收起的问题,与代码变更的目的完全相符。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

1 participant