fix(editor): focus follows the action after a touch commit
This commit is contained in:
1 parent
df46390bdb
commit
03e85a7c67
5 files changed
+135
-4
No files matched your search
@@ -748,3 +748,48 @@ describe('Safari: « Déplacer le point » clicked with the focus left on the sl
|
||||
expect(useAnnotationWork.getState().mode?.kind).toBe('move')
|
||||
})
|
||||
})
|
||||
|
||||
describe('Safari: the focus after a press that commits a pending change', () => {
|
||||
const tapDrag = (el: Element) => {
|
||||
const init = {
|
||||
pointerId: 1,
|
||||
isPrimary: true,
|
||||
button: 0,
|
||||
buttons: 1,
|
||||
pointerType: 'mouse',
|
||||
}
|
||||
fireEvent.pointerDown(el, { ...init, clientX: 50, clientY: 50 })
|
||||
fireEvent.pointerMove(el, { ...init, clientX: 80, clientY: 80 })
|
||||
}
|
||||
|
||||
it('a press on the point handle commits the slider change and focuses the handle', async () => {
|
||||
await mount(withPoints(point('a', 50, 50, 5), point('b', 20, 20, 8)))
|
||||
await select()
|
||||
act(() => slider().focus())
|
||||
fireEvent.keyDown(slider(), { key: 'PageUp' })
|
||||
const before = depth()
|
||||
tapDrag(handle().querySelector('[data-handle]')!)
|
||||
expect(depth()).toBe(before + 1)
|
||||
expect(document.activeElement).toBe(handle())
|
||||
})
|
||||
|
||||
it('a press on the handle commits its arrow series and keeps the handle focused', async () => {
|
||||
await mount(withPoints(point('a', 50, 50, 5)))
|
||||
await select()
|
||||
act(() => handle().focus())
|
||||
fireEvent.keyDown(handle(), { key: 'ArrowRight' })
|
||||
const before = depth()
|
||||
tapDrag(handle().querySelector('[data-handle]')!)
|
||||
expect(depth()).toBe(before + 1)
|
||||
expect(document.activeElement).toBe(handle())
|
||||
})
|
||||
|
||||
it('« Redessiner » and « Désélectionner » never leave the focus on body', async () => {
|
||||
await mount(withPoints(point('a', 50, 50, 5)))
|
||||
await select()
|
||||
act(() => slider().focus())
|
||||
fireEvent.keyDown(slider(), { key: 'PageUp' })
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Désélectionner' }))
|
||||
expect(document.activeElement).not.toBe(document.body)
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user