Skip to content

fix(picker): 修复第一次modalValue值为空,打开面板后直接点击确认按钮,beforeConfirm回调中value参数为空串的问题#1455

Open
NeverGiveUp1995 wants to merge 2 commits intoMoonofweisheng:masterfrom
NeverGiveUp1995:fix/add-wd-picker-before-confirm-no-value
Open

fix(picker): 修复第一次modalValue值为空,打开面板后直接点击确认按钮,beforeConfirm回调中value参数为空串的问题#1455
NeverGiveUp1995 wants to merge 2 commits intoMoonofweisheng:masterfrom
NeverGiveUp1995:fix/add-wd-picker-before-confirm-no-value

Conversation

@NeverGiveUp1995
Copy link

@NeverGiveUp1995 NeverGiveUp1995 commented Jan 30, 2026

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

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

🔗 相关 Issue

💡 需求背景和解决方案

示例代码

<script setup lang="ts">
import { ref } from 'vue'

const animalList = ref([
  { label: '狗', value: 'dog' },
  { label: '猫', value: 'cat' },
  { label: '鸟', value: 'bird' },
])
const selectedAnimal = ref()

const beforeConfirm = (value, resolve) => {
  // 这里取不到值
  console.log('beforeConfirm', value)
  resolve(true)
}

const confirm = ({ value, selectedItem }) => {
  // 这里能取到值
  console.log('confirm', value, selectedItem)
}
</script>

<template>
  <view class="root-container">
    <wd-picker
        :before-confirm="beforeConfirm"
        v-model="selectedAnimal"
        :columns="animalList"
        @confirm="confirm"
    />
  </view>
</template>

<style scoped>
.root-container {
  padding: 5rem 2.5rem;
  text-align: center;
}
</style>

演示效果

534490691-d6d8e270-e7b0-46de-9c8a-4cf54bef80c2.mp4

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

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

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

Summary by CodeRabbit

发布说明

  • Bug 修复
    • 改进了选择器确认流程,确保在用户未滑动选择器时能正确获取当前选择的值,提升了用户交互的准确性。

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

@netlify
Copy link

netlify bot commented Jan 30, 2026

Deploy Preview for wot-design-uni ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 19b9c34
🔍 Latest deploy log https://app.netlify.com/projects/wot-design-uni/deploys/697c0ec58c8da20008666335
😎 Deploy Preview https://deploy-preview-1455--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

coderabbitai bot commented Jan 30, 2026

概览

wd-picker.vue 中的 onConfirm 流程现在在调用 beforeConfirm 之前从 pickerView 检索当前值,而不是使用之前存储的 pickerValue,以确保当初始 modelValue 未定义且用户确认时不滑动选择器时使用最新的选择器视图状态。

变更

内聚群组 / 文件 摘要
Picker 确认流程修复
src/uni_modules/wot-design-uni/components/wd-picker/wd-picker.vue
修改 onConfirm 流程以在调用 beforeConfirm 前从 pickerView 获取当前值,确保当未设置初始 modelValue 且用户未滑动选择器直接确认时使用最新的选择器状态。

预估代码审查工作量

🎯 2 (简单) | ⏱️ ~10 分钟

可能相关的 PR

  • PR #518: 两个 PR 都修改了 wd-picker 和 wd-picker-view 之间选择值的获取和处理方式(确保使用当前选择器视图值以及修复动态列选择),因此相关联。

建议审查人员

  • Moonofweisheng

诗歌

🐰 选择器悄悄更新妙,

确认前先看当前值,

未曾滑动也不怕,

最新状态已在手,

轻轻一点,完美呈现!✨

🚥 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 标题准确描述了PR的主要改动:修复了当初始modalValue为空时,直接点击确认按钮导致beforeConfirm回调中value参数为空串的问题,与changeset中的实际代码改动完全对应。
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.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

🧪 Unit Test Generation v2 is now available!

We have significantly improved our unit test generation capabilities.

To enable: Add this to your .coderabbit.yaml configuration:

reviews:
  finishing_touches:
    unit_tests:
      enabled: true

Try it out by using the @coderabbitai generate unit tests command on your code files or under ✨ Finishing Touches on the walkthrough!

Have feedback? Share your thoughts on our Discord thread!


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.

@vercel
Copy link

vercel bot commented Jan 30, 2026

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

A member of the Team first needs to authorize it.

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