design-system icon indicating copy to clipboard operation
design-system copied to clipboard

feat(DatePicker): Migrate to react-day-picker v8

Open jpveooys opened this issue 3 years ago • 5 comments

Related issue

#2871 #2872

Overview

Work in progress PR to migrate DatePicker to react-day-picker v8.

Link to preview

todo

Reason

To resolve various accessibility and keyboard navigation problems.

Work carried out

  • [x] Migrate DatePicker to react-day-picker v8
  • [x] Fix bug with shading of keyboard range selection when second date is blurred
  • [x] Focus selected date or current date on open

Demo

todo

Developer notes

todo

jpveooys avatar Jan 18 '22 15:01 jpveooys

@c9qsm62x It was added for coverage IIRC as those code paths still exist in the useInput hook.

I think the test has stopped doing what it was meant to since user-event was updated to v14 – fireEvent.keyDown(input, { key: 'Enter' }) probably makes more sense.

jpveooys avatar Aug 17 '22 08:08 jpveooys

Test DatePicker › when a single date picker is rendered and the picker is opened › when Shift-Tab is pressed once › traps the focus within the picker

it looks like this behaviour has changed in V8
https://react-day-picker.js.org/basics/keyboard#example Having a look at this example it looks like when a date is in focus and you press shift+tab it will focus on the next month button.

c9qsm62x avatar Aug 17 '22 09:08 c9qsm62x

Yep that test looks wrong now as the initial focus is now set to the selected date.

Should be something like this I think:

    describe('when Tab is pressed once', () => {
      beforeEach(async () => {
        await user.tab()
      })

      it('traps the focus within the picker', () => {
        expect(
          wrapper.getByLabelText(PREVIOUS_MONTH_BUTTON_LABEL)
        ).toHaveFocus()
      })

      describe('and Shift-Tab is then pressed once', () => {
        beforeEach(() => {
          return user.tab({ shift: true })
        })

        it('still traps the focus within the picker', () => {
          expect(
            wrapper.getByRole('button', { name: '5th December (Thursday)' })
          ).toHaveFocus()
        })
      })
    })

jpveooys avatar Aug 17 '22 09:08 jpveooys

Closing for now because it's very stale - hoping to come back to this soon.

m7kvqbe1 avatar Apr 30 '24 12:04 m7kvqbe1