Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: setup and state #714

Closed
ph-fritsche opened this issue Aug 9, 2021 · 2 comments
Closed

feat: setup and state #714

ph-fritsche opened this issue Aug 9, 2021 · 2 comments
Labels
enhancement New feature or request
Milestone

Comments

@ph-fritsche
Copy link
Member

ph-fritsche commented Aug 9, 2021

Problem description:

Suggested solution:

  1. Add an abstract API that allows to e.g. press a mouse button without releasing it, keeps track of pointer state and will be used internally by all convenience functions like click or dblClick.

    const pointerState = user.pointer('[MouseLeft>]')
    user.pointer('[/MouseLeft]', {pointerState})

    feat: pointer API #742

  2. Add a userEvent.setup API that exports all our APIs bound to a shared state.

    const user = userEvent.setup({document})
    user.keyboard('[ControlLeft>]')
    user.click(element) // dispatch pointer events with ctrlKey=true

    feat: setup #743

  3. Use one abstraction to keep track of initial value, display value and selection across all our APIs.
    Our work around should be applied to the active element and be added to the capture phase of focus by userEvent.setup or any other of our APIs that is called earlier.
    See https://github.com/testing-library/user-event/blob/main/src/keyboard/shared/fireInputEvent.ts and https://github.com/testing-library/user-event/blob/main/src/utils/edit/selectionRange.ts

    feat: document state #744

@ph-fritsche ph-fritsche added enhancement New feature or request needs specification The desired behavior is not defined yet labels Aug 9, 2021
@ph-fritsche
Copy link
Member Author

@kentcdodds @nickmccurdy @MichaelDeBoey

@kentcdodds
Copy link
Member

Number 1 and 2 feel like how DOM Testing Library exports the unbound queries as well as pre-bound ones on screen. For that reason I kind of like the idea of both of those.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants