From 7fa7e83ce774867d7937355c8c022715b3468961 Mon Sep 17 00:00:00 2001 From: Venkatesh Rajendran <156048885+venkateshr06@users.noreply.github.com> Date: Mon, 29 Jan 2024 10:01:08 +0530 Subject: [PATCH] fix(date-picker): ignore non-string values in date service parser (#1169) ## PR Checklist Please check if your PR fulfills the following requirements: - [ ] Tests for the changes have been added (for bug fixes / features) - [ ] Docs have been added / updated (for bug fixes / features) - [ ] If applicable, have a visual design approval ## PR Type What kind of change does this PR introduce? - [x] Bugfix - [ ] Feature - [ ] Code style update (formatting, local variables) - [ ] Refactoring (no functional changes, no api changes) - [ ] Build related changes - [ ] CI related changes - [ ] Documentation content changes - [ ] Other... Please describe: ## What is the current behavior? If Date object is passed to the control and that's being passed to 'getDateValueFromDateString' which accepts strings only -- the control breaks and freezes. Issue Number: #975 CDE-1578 ## What is the new behavior? Ignore non-string values which are passed to that function. ## Does this PR introduce a breaking change? - [ ] Yes - [x] No ## Other information Co-authored-by: Venkatesh Rajendran (cherry picked from commit 64f10c4f05f2e6bce98d1a922c355321fe9fa623) --- .../angular/src/forms/datepicker/providers/date-io.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/angular/src/forms/datepicker/providers/date-io.service.ts b/projects/angular/src/forms/datepicker/providers/date-io.service.ts index df7cfa023d..94be7d964e 100644 --- a/projects/angular/src/forms/datepicker/providers/date-io.service.ts +++ b/projects/angular/src/forms/datepicker/providers/date-io.service.ts @@ -93,7 +93,7 @@ export class DateIOService { } getDateValueFromDateString(date: string): Date { - if (!date) { + if (!date || typeof date !== 'string') { return null; } const dateParts: string[] = date.match(USER_INPUT_REGEX);