From 0dc09cab8c33949490055b50bc22a121b5ead6bc Mon Sep 17 00:00:00 2001 From: neverland Date: Sat, 4 Jun 2022 20:17:16 +0800 Subject: [PATCH] fix(Area): failed to render picker mask after reopened (#10664) --- .../src/area/test/__snapshots__/index.spec.js.snap | 8 ++++++++ packages/vant/src/picker/Picker.tsx | 11 ++++++----- packages/vant/src/picker/PickerColumn.tsx | 3 +++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/packages/vant/src/area/test/__snapshots__/index.spec.js.snap b/packages/vant/src/area/test/__snapshots__/index.spec.js.snap index 67059984e..4d0aac653 100644 --- a/packages/vant/src/area/test/__snapshots__/index.spec.js.snap +++ b/packages/vant/src/area/test/__snapshots__/index.spec.js.snap @@ -122,6 +122,14 @@ exports[`should render two columns when columns-num prop is two 1`] = ` +
+
+
+
`; diff --git a/packages/vant/src/picker/Picker.tsx b/packages/vant/src/picker/Picker.tsx index 049b1bd0c..8e3bb7c09 100644 --- a/packages/vant/src/picker/Picker.tsx +++ b/packages/vant/src/picker/Picker.tsx @@ -164,11 +164,12 @@ export default defineComponent({ formattedColumns.value = columns as PickerObjectColumn[]; } - hasOptions.value = formattedColumns.value.some( - (item) => - item[columnsFieldNames.value.values] && - item[columnsFieldNames.value.values].length !== 0 - ); + hasOptions.value = + formattedColumns.value.some( + (item) => + item[columnsFieldNames.value.values] && + item[columnsFieldNames.value.values].length !== 0 + ) || children.some((item) => item.hasOptions); }; // get indexes of all columns diff --git a/packages/vant/src/picker/PickerColumn.tsx b/packages/vant/src/picker/PickerColumn.tsx index 2768c8dd7..66f917526 100644 --- a/packages/vant/src/picker/PickerColumn.tsx +++ b/packages/vant/src/picker/PickerColumn.tsx @@ -283,6 +283,8 @@ export default defineComponent({ const getValue = (): PickerOption => state.options[state.index]; + const hasOptions = () => state.options.length; + setIndex(state.index); useParent(PICKER_KEY); @@ -292,6 +294,7 @@ export default defineComponent({ getValue, setValue, setOptions, + hasOptions, stopMomentum, });