diff --git a/package-lock.json b/package-lock.json index d34562d2..37ebbc96 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18803,7 +18803,7 @@ }, "packages/comet-uswds": { "name": "@metrostar/comet-uswds", - "version": "2.1.1", + "version": "2.1.2", "license": "Apache-2.0", "dependencies": { "@uswds/uswds": "3.8.1", diff --git a/packages/comet-uswds/package.json b/packages/comet-uswds/package.json index e58ba3b7..216e5bbd 100644 --- a/packages/comet-uswds/package.json +++ b/packages/comet-uswds/package.json @@ -1,6 +1,6 @@ { "name": "@metrostar/comet-uswds", - "version": "2.1.1", + "version": "2.1.2", "description": "React with TypeScript Component Library based on USWDS 3.0.", "license": "Apache-2.0", "main": "./dist/cjs/index.js", diff --git a/packages/comet-uswds/src/components/date-picker/date-picker.tsx b/packages/comet-uswds/src/components/date-picker/date-picker.tsx index 5711d48a..20e6dcc8 100644 --- a/packages/comet-uswds/src/components/date-picker/date-picker.tsx +++ b/packages/comet-uswds/src/components/date-picker/date-picker.tsx @@ -54,7 +54,11 @@ export const DatePicker = ({ useLayoutEffect(() => { const datePickerElement = datePickerRef.current as HTMLInputElement; - datePicker.on(datePickerElement); + const datePickerWrapper = datePickerElement.querySelector( + '.usa-date-picker__wrapper', + ) as HTMLInputElement; + if (!datePickerWrapper) datePicker.on(datePickerElement); + const externalInput = datePicker.getDatePickerContext(datePickerElement).externalInputEl; if (onChange) { externalInput.addEventListener('change', onChange); @@ -63,9 +67,10 @@ export const DatePicker = ({ if (onChange) { externalInput.removeEventListener('change', onChange); } - datePicker.off(datePickerElement); + /* v8 ignore next */ + if (datePickerWrapper) datePicker.off(datePickerElement); }; - }); + }, []); const datePickerAttributes: DatePickerAttributes = {}; if (minDate) datePickerAttributes['data-min-date'] = getDateString(minDate);