From ee6f3304d4f37424b974e5c82f6c9f305083cc00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E6=9C=BA=E5=99=A8=E4=BA=BA?= Date: Mon, 15 Jan 2024 10:55:23 +0800 Subject: [PATCH 1/2] fix: timePicker should not have header --- docs/examples/debug.tsx | 1 + src/PickerInput/Popup/PopupPanel.tsx | 3 +++ src/PickerPanel/context.ts | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/docs/examples/debug.tsx b/docs/examples/debug.tsx index f5d9fa6b8..c3815d4d2 100644 --- a/docs/examples/debug.tsx +++ b/docs/examples/debug.tsx @@ -151,6 +151,7 @@ export default () => { {...sharedLocale} disabledDate={(date) => date.isBefore(dayjs())} open + picker="time" ref={singleRef} suffixIcon="🧶" onChange={(...args) => { diff --git a/src/PickerInput/Popup/PopupPanel.tsx b/src/PickerInput/Popup/PopupPanel.tsx index 1c48c413a..94cfccc4f 100644 --- a/src/PickerInput/Popup/PopupPanel.tsx +++ b/src/PickerInput/Popup/PopupPanel.tsx @@ -61,6 +61,8 @@ export default function PopupPanel( }, }; + const hideHeader = picker === 'time'; + // ====================== Limitation ====================== const needLimit = React.useCallback( (currentPickerValue: DateType) => { @@ -96,6 +98,7 @@ export default function PopupPanel( ...props, hoverValue: null, hoverRangeValue: null, + hideHeader, }; if (range) { diff --git a/src/PickerPanel/context.ts b/src/PickerPanel/context.ts index 9a42cd593..bda5c26f0 100644 --- a/src/PickerPanel/context.ts +++ b/src/PickerPanel/context.ts @@ -104,3 +104,7 @@ export interface PickerHackContextProps { * Internal usage for RangePicker to not to show the operation arrow */ export const PickerHackContext = React.createContext({}); + +if (process.env.NODE_ENV !== 'production') { + PickerHackContext.displayName = 'PickerHackContext'; +} From 00ea4d713c59152ce7ef4b3c4890bf6ace7104c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E6=9C=BA=E5=99=A8=E4=BA=BA?= Date: Mon, 15 Jan 2024 10:59:44 +0800 Subject: [PATCH 2/2] test: add test case --- docs/examples/debug.tsx | 1 - tests/picker.spec.tsx | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/examples/debug.tsx b/docs/examples/debug.tsx index c3815d4d2..f5d9fa6b8 100644 --- a/docs/examples/debug.tsx +++ b/docs/examples/debug.tsx @@ -151,7 +151,6 @@ export default () => { {...sharedLocale} disabledDate={(date) => date.isBefore(dayjs())} open - picker="time" ref={singleRef} suffixIcon="🧶" onChange={(...args) => { diff --git a/tests/picker.spec.tsx b/tests/picker.spec.tsx index 1dc33104e..c36b0949a 100644 --- a/tests/picker.spec.tsx +++ b/tests/picker.spec.tsx @@ -605,7 +605,10 @@ describe('Picker.Basic', () => { it('time should display now', () => { const onCalendarChange = jest.fn(); const { container } = render(); + openPicker(container); + expect(document.querySelector('.rc-picker-header')).toBeFalsy(); + fireEvent.click(document.querySelector('.rc-picker-now > a')); expect(