Skip to content

Commit

Permalink
fix(datepicker): restore toggle open calendar functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
jaketrent committed Nov 11, 2020
1 parent 7432b68 commit def6c19
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/datepicker/src/react/__specs__/index.spec.tsx
Expand Up @@ -24,6 +24,19 @@ describe('DatePicker', () => {
expect(ref.current).not.toBeNull()
})

it('opens calendar on icon click', () => {
const { getByText, getByLabelText, container, rerender } = render(
<DatePicker value="1/20/1993" />
)
const icon = getByLabelText('calendar icon', { selector: 'svg' }) // container.querySelector<HTMLButtonElement>('button')

fireEvent.click(icon)

const calendar = getByText('January 1993')

expect(calendar).toBeInTheDocument()
})

describe('onBlur prop', () => {
it('should call onBlur when onBlur is called for a valid date', () => {
const onBlurMock = jest.fn()
Expand Down
1 change: 1 addition & 0 deletions packages/datepicker/src/react/index.tsx
Expand Up @@ -183,6 +183,7 @@ const DatePicker = React.forwardRef((props, ref) => {

function handleIconClick(evt: React.MouseEvent) {
evt.preventDefault()
toggleIsOpen()
}

const handleKeyDown = combineFns((evt: React.KeyboardEvent) => {
Expand Down

0 comments on commit def6c19

Please sign in to comment.