Repository: ant-design/ant-design-mobile
Pull request #6676 (2024-07-23 09:59:34)

feat(CalendarPickerView): title support boolean value to control whether to hide
CalendarPickerView 的 title 可以通过配置 false 来隐藏

github-actions[bot]: PR preview has been successfully built and deployed to https://antd-mobile-preview-pr-6676.surge.sh
crazyair: ![image](https://github.com/user-attachments/assets/eabc7af6-44c8-41e9-8587-37ad8717b6e0)

感觉有个问题，以前 title 为假值，可以显示默认的 title
zombieJ: > 感觉有个问题，以前 title 为假值，可以显示默认的 title，保险起见，可以加 showHeader

`??` 不会穿透 `false`
crazyair: > > 感觉有个问题，以前 title 为假值，可以显示默认的 title，保险起见，可以加 showHeader
> 
> `??` 不会穿透 `false`

行，那这个没啥问题

Patch:
diff --git a/src/components/calendar-picker-view/calendar-picker-view.en.md b/src/components/calendar-picker-view/calendar-picker-view.en.md
index 101399cd9..d7aad496a 100644
--- a/src/components/calendar-picker-view/calendar-picker-view.en.md
+++ b/src/components/calendar-picker-view/calendar-picker-view.en.md
@@ -25,7 +25,7 @@ Only the simplest content area is shown here, and other more usages can be consu
 | renderBottom | The bottom information of date render function. | `(date: Date) => ReactNode \| null \| undefined` | - |
 | selectionMode | The selection mode. Disable selection when this prop is not set. | `'single' \| 'range'` | - |
 | shouldDisableDate | Set whether the date is disable selection. The min and max Settings are ignored | `(date: Date) => boolean` | - |
-| title | The title of calendar | `React.ReactNode` | `Date selection` |
+| title | The title of calendar | `React.ReactNode \| false` | `Date selection` |
 | value | The selected date or date range. | `Date \| null` when selection mode is "single". `[Date, Date] \| null` when selection mode is "range" | - |
 | weekStartsOn | Week starts on which day. | `'Monday' \| 'Sunday'` | `'Sunday'` |
 | renderDate | Custom date rendering. | `(date: Date) => ReactNode` | - | 5.28.0 |
diff --git a/src/components/calendar-picker-view/calendar-picker-view.tsx b/src/components/calendar-picker-view/calendar-picker-view.tsx
index 83a38591e..58a300842 100644
--- a/src/components/calendar-picker-view/calendar-picker-view.tsx
+++ b/src/components/calendar-picker-view/calendar-picker-view.tsx
@@ -41,7 +41,7 @@ export type CalendarPickerViewRef = {
 }
 
 export type CalendarPickerViewProps = {
-  title?: React.ReactNode
+  title?: React.ReactNode | false
   confirmText?: string
   weekStartsOn?: 'Monday' | 'Sunday'
   renderTop?: (date: Date) => React.ReactNode
@@ -117,6 +117,8 @@ export const CalendarPickerView = forwardRef<
     dayjs(dateRange ? dateRange[0] : today).date(1)
   )
 
+  const showHeader = props.title !== false
+
   // =============================== Scroll ===============================
   const context = useContext(Context)
   const scrollTo = useSyncScroll(current, context.visible, bodyRef)
@@ -356,7 +358,7 @@ export const CalendarPickerView = forwardRef<
   return withNativeProps(
     props,
     <div className={classPrefix}>
-      {header}
+      {showHeader && header}
       {mark}
       {body}
     </div>
diff --git a/src/components/calendar-picker-view/calendar-picker-view.zh.md b/src/components/calendar-picker-view/calendar-picker-view.zh.md
index 69a5d0644..7e212456c 100644
--- a/src/components/calendar-picker-view/calendar-picker-view.zh.md
+++ b/src/components/calendar-picker-view/calendar-picker-view.zh.md
@@ -25,7 +25,7 @@ CalendarPickerView 是 [CalendarPicker](/zh/components/calendar-picker) 的内
 | renderBottom | 日期底部信息的渲染函数 | `(date: Date) => ReactNode \| null \| undefined` | - |
 | selectionMode | 选择模式，不设置的话表示不支持选择 | `'single' \| 'range'` | - |
 | shouldDisableDate | 判断日期是否可选，使用后会忽略 min 和 max 设置 | `(date: Date) => boolean` | - |
-| title | 日期选择器的标题 | `React.ReactNode` | `日期选择` |
+| title | 日期选择器的标题 | `React.ReactNode \| false` | `日期选择` |
 | value | 选择的日期 | 单选模式下为 `Date \| null`，多选模式下为 `[Date, Date] \| null` | - |
 | weekStartsOn | 每周以周几作为第一天 | `'Monday' \| 'Sunday'` | `'Sunday'` |
 | renderDate | 自定义日期渲染 | `(date: Date) => ReactNode` | - | 5.28.0 |


Test patch:
diff --git a/src/components/calendar-picker-view/tests/calendar-picker-view.test.tsx b/src/components/calendar-picker-view/tests/calendar-picker-view.test.tsx
index 37d826643..6266e2ca1 100644
--- a/src/components/calendar-picker-view/tests/calendar-picker-view.test.tsx
+++ b/src/components/calendar-picker-view/tests/calendar-picker-view.test.tsx
@@ -161,6 +161,12 @@ describe('Calendar', () => {
     expect(document.getElementsByClassName('custom-cell').length).toBe(31)
   })
 
+  test('title hidden', () => {
+    render(<CalendarPickerView title={false} />)
+
+    expect(document.querySelector(`.${classPrefix}-header`)).toBeNull()
+  })
+
   test('not fill empty cells if unnecessary', () => {
     const { container } = render(
       <CalendarPickerView