Skip to content

Commit

Permalink
Fix date picker rerender issue. Update comet-uswds to next patch vers…
Browse files Browse the repository at this point in the history
…ion.
  • Loading branch information
jbouder committed Jun 26, 2024
1 parent ada16dd commit a3a6b67
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/comet-uswds/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
11 changes: 8 additions & 3 deletions packages/comet-uswds/src/components/date-picker/date-picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit a3a6b67

Please sign in to comment.