Skip to content

Commit 3120c95

Browse files
authored
fix: TimePicker should not show header (#739)
* fix: timePicker should not have header * test: add test case
1 parent f07bbaf commit 3120c95

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

src/PickerInput/Popup/PopupPanel.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ export default function PopupPanel<DateType extends object = any>(
6161
},
6262
};
6363

64+
const hideHeader = picker === 'time';
65+
6466
// ====================== Limitation ======================
6567
const needLimit = React.useCallback(
6668
(currentPickerValue: DateType) => {
@@ -96,6 +98,7 @@ export default function PopupPanel<DateType extends object = any>(
9698
...props,
9799
hoverValue: null,
98100
hoverRangeValue: null,
101+
hideHeader,
99102
};
100103

101104
if (range) {

src/PickerPanel/context.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,7 @@ export interface PickerHackContextProps {
104104
* Internal usage for RangePicker to not to show the operation arrow
105105
*/
106106
export const PickerHackContext = React.createContext<PickerHackContextProps>({});
107+
108+
if (process.env.NODE_ENV !== 'production') {
109+
PickerHackContext.displayName = 'PickerHackContext';
110+
}

tests/picker.spec.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,10 @@ describe('Picker.Basic', () => {
605605
it('time should display now', () => {
606606
const onCalendarChange = jest.fn();
607607
const { container } = render(<DayPicker onCalendarChange={onCalendarChange} picker="time" />);
608+
608609
openPicker(container);
610+
expect(document.querySelector('.rc-picker-header')).toBeFalsy();
611+
609612
fireEvent.click(document.querySelector('.rc-picker-now > a'));
610613

611614
expect(

0 commit comments

Comments
 (0)