Skip to content

Commit

Permalink
fix(ui): fix failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
gjaskiewicz@objectivity.co.uk committed Nov 27, 2024
1 parent a301ec8 commit 5f3b0e3
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,13 @@ export const DateTimePicker: React.FC<DateTimePickerProps> = ({

const hasLength = (node: React.ReactNode) => (typeof node === "string" || Array.isArray(node)) && node.length

const updateFlatpickrInstance = (newKeys: Partial<flatpickr.Instance> | null) => {
if (flatpickrInstanceRef.current) {
const updateFlatpickrInstance = (newKeys: flatpickr.Instance | null) => {
if (flatpickrInstanceRef.current === null) {
flatpickrInstanceRef.current = newKeys
} else if (newKeys !== null) {
flatpickrInstanceRef.current = {
...flatpickrInstanceRef.current,
...(newKeys || {}),
...newKeys,
}
}
}
Expand Down Expand Up @@ -294,11 +296,11 @@ export const DateTimePicker: React.FC<DateTimePickerProps> = ({

const destroyFlatpickrInstance = () => {
const instance = flatpickrInstanceRef.current
if (instance) {
instance.destroy()
setTheDate({})
flatpickrInstanceRef.current = null // Not sure if this is actually necessary?
}
//if (instance) {
instance?.destroy()
setTheDate({})
flatpickrInstanceRef.current = null // Not sure if this is actually necessary?
//}
}

useEffect(() => {
Expand Down

0 comments on commit 5f3b0e3

Please sign in to comment.