Skip to content

Commit

Permalink
fix(datepicker): fix issues with leadingZeros config option (#754)
Browse files Browse the repository at this point in the history
added `return` statements to `setLeadingZeros` method to prevent calling `toLowerCase` on a boolean
value.

fix #753
  • Loading branch information
chrispymm authored Sep 23, 2024
1 parent 778279d commit 5224918
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
20 changes: 20 additions & 0 deletions docs/examples/date-picker-leading-zeros/index.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
layout: layouts/example.njk
title: Date Picker (example)
arguments: date-picker
figma_link: https://www.figma.com/design/N2xqOFkyehXwcD9DxU1gEq/MoJ-Figma-Kit?node-id=792-861&t=6DfPOX7RAnjrVE0j-0
---

{%- from "moj/components/date-picker/macro.njk" import mojDatePicker -%}

{{ mojDatePicker({
id: "date",
name: "date",
label: {
text: "Date"
},
hint: {
text: "For example, 17/5/2024."
},
leadingZeros: "true"
}) }}
2 changes: 2 additions & 0 deletions src/moj/components/date-picker/date-picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,9 +411,11 @@ Datepicker.prototype.setLeadingZeros = function () {
if (typeof this.config.leadingZeros !== "boolean") {
if (this.config.leadingZeros.toLowerCase() === "true") {
this.config.leadingZeros = true;
return;
}
if (this.config.leadingZeros.toLowerCase() === "false") {
this.config.leadingZeros = false;
return;
}
}
};
Expand Down

0 comments on commit 5224918

Please sign in to comment.