Skip to content

Commit

Permalink
fix(ui): fix DateTimePicker runtime errors (#702)
Browse files Browse the repository at this point in the history
  • Loading branch information
gjaskiewicz and [email protected] authored Jan 2, 2025
1 parent 92719cf commit 212e32b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/kind-maps-shout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@cloudoperators/juno-ui-components": patch
---

Fix errors in DateTimePicker
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ export const DateTimePicker: React.FC<DateTimePickerProps> = ({
enableSeconds: enableSeconds,
enableTime: enableTime,
hourIncrement: hourIncrement,
locale: (locale || undefined) as LocaleKey | Partial<CustomLocale>,
locale: (locale || "default") as LocaleKey | Partial<CustomLocale>,
maxDate: (maxDate || undefined) as DateOption,
minDate: (minDate || undefined) as DateOption,
minuteIncrement: minuteIncrement,
Expand Down Expand Up @@ -420,7 +420,7 @@ export const DateTimePicker: React.FC<DateTimePickerProps> = ({
}, [hourIncrement])

useEffect(() => {
flatpickrInstanceRef.current?.set("locale", locale)
flatpickrInstanceRef.current?.set("locale", locale || "default")
}, [locale])

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import React from "react"
import { cleanup, render, screen, waitFor } from "@testing-library/react"
import { cleanup, render, screen, waitFor, act } from "@testing-library/react"
import userEvent from "@testing-library/user-event"
import { DateTimePicker } from "./index"
import { PortalProvider } from "../PortalProvider/PortalProvider.component"
Expand Down Expand Up @@ -863,8 +863,10 @@ describe("DateTimePicker", () => {
const input = screen.getByRole("textbox")
await waitFor(() => user.click(input))

const focusEvent = new FocusEvent("focus", { bubbles: true, composed: true })
document.body.dispatchEvent(focusEvent)
act(() => {
const focusEvent = new FocusEvent("focus", { bubbles: true, composed: true })
document.body.dispatchEvent(focusEvent)
})

expect(mockOnClose).toHaveBeenCalled()
})
Expand Down

0 comments on commit 212e32b

Please sign in to comment.