-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[@mantine/dates] TimeInput: Fix am/pm input not working with keyboard…
… events with React 18 (#1322)
- Loading branch information
1 parent
707db1d
commit 6cc79d8
Showing
4 changed files
with
55 additions
and
2 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
src/mantine-dates/src/components/TimeInputBase/AmPmInput/AmPmInput.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import { AmPmInput } from './AmPmInput'; | ||
|
||
describe('@mantine/dates/TimeInputBase/AmPmInput', () => { | ||
it.each([['a'], ['p'], ['{arrowdown}']])('triggers onChange once for %s', (value) => { | ||
const spy = jest.fn(); | ||
const { container } = render(<AmPmInput onChange={spy} size="md" />); | ||
userEvent.type(container.querySelector('input'), value); | ||
expect(spy).toHaveBeenCalledTimes(1); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/mantine-demos/src/demos/dates/TimeRangeInput/TimeRangeInput.demo.format.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import dayjs from 'dayjs'; | ||
import React from 'react'; | ||
import { Container } from '@mantine/core'; | ||
import { TimeRangeInput } from '@mantine/dates'; | ||
|
||
const code = ` | ||
import dayjs from 'dayjs'; | ||
import { TimeRangeInput } from '@mantine/dates'; | ||
function Demo() { | ||
return ( | ||
<TimeRangeInput | ||
label="Appointment time" | ||
format="12" | ||
defaultValue={[new Date(), dayjs(new Date()).add(30, 'minutes').toDate()]} | ||
/> | ||
); | ||
} | ||
`; | ||
|
||
function Demo() { | ||
return ( | ||
<Container size={340}> | ||
<TimeRangeInput | ||
label="Appointment time" | ||
format="12" | ||
defaultValue={[new Date(), dayjs(new Date()).add(30, 'minutes').toDate()]} | ||
/> | ||
</Container> | ||
); | ||
} | ||
|
||
export const format: MantineDemo = { | ||
type: 'demo', | ||
code, | ||
component: Demo, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { usage } from './TimeRangeInput.demo.usage'; | ||
export { withSeconds } from './TimeRangeInput.demo.withSeconds'; | ||
export { format } from './TimeRangeInput.demo.format'; |