From e5b527bfed95c9ce95bcb4309ddeec9cfcd9a337 Mon Sep 17 00:00:00 2001 From: balajis-qb Date: Thu, 19 Feb 2026 17:47:33 +0530 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor:=20Change=20TimeP?= =?UTF-8?q?icker's=20header=20from=20div=20to=20h2=20and=20update=20styles?= =?UTF-8?q?=20to=20match=20with=20DatePicker's=20header?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Updated the time header in the DatePicker component from a div to an h2 element for better semantic structure. - Adjusted the SCSS styles to include the new h2 class for consistent styling. - Added a test to ensure the default time caption is rendered correctly. --- src/stylesheets/datepicker.scss | 3 ++- src/test/show_time_test.test.tsx | 8 ++++++++ src/time.tsx | 4 ++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/stylesheets/datepicker.scss b/src/stylesheets/datepicker.scss index 57b8445f9..b86954f10 100644 --- a/src/stylesheets/datepicker.scss +++ b/src/stylesheets/datepicker.scss @@ -176,7 +176,8 @@ font-size: $datepicker__font-size * 1.18; } -h2.react-datepicker__current-month { +h2.react-datepicker__current-month, +h2.react-datepicker-time__header { padding: 0; margin: 0; } diff --git a/src/test/show_time_test.test.tsx b/src/test/show_time_test.test.tsx index 97d5531b2..8fc59e0c6 100644 --- a/src/test/show_time_test.test.tsx +++ b/src/test/show_time_test.test.tsx @@ -20,6 +20,14 @@ describe("DatePicker", () => { expect(timeComponent).not.toBeNull(); }); + it("should have default time caption", () => { + const { container } = render(); + const timeComponent = container.querySelector( + "h2.react-datepicker-time__header", + ); + expect(timeComponent).not.toBeNull(); + }); + it("should have custom time caption", () => { const { container } = render(); diff --git a/src/time.tsx b/src/time.tsx index c02dc2369..4f9aec44e 100644 --- a/src/time.tsx +++ b/src/time.tsx @@ -300,9 +300,9 @@ export default class Time extends Component { this.header = header; }} > -
+

{this.props.timeCaption} -

+ ); };