Skip to content

Conversation

@nimaebra
Copy link
Contributor

Fix code example of clear API in user-events v13 docs.

The current code example does not work and causes confusion because React value prop without an onChange handler causes the field to be read-only. Also value attribute is null.

So I changed two things:

  • value to defaultValue prop
  • toHaveAttribute('value', '') to toHaveValue('')

The example code for clear in Utility APIs is also following this method.

@MatanBobi
Copy link
Member

Hi @nimaebra, thanks for taking the time to open this one :)
I'm actually not sure the textarea element supports defaultValue based on the HTML spec

@nimaebra
Copy link
Contributor Author

@MatanBobi, Thanks for your response 💯
The code example is written in react and according to the react docs, textarea supports defaultValue.
Additionally, as I mentioned in my quote, the clear code example of Utility APIs is also uses defaultValue for textarea.

Copy link
Member

@ph-fritsche ph-fritsche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking the time to fix this ❤️

@MatanBobi MatanBobi merged commit 5ef54b4 into testing-library:main Feb 6, 2022
@MatanBobi
Copy link
Member

Thanks! :)
@all-contributors please add @nimaebra for docs :)

@MatanBobi
Copy link
Member

@all-contributors please add @ph-fritsche for review :)

@allcontributors
Copy link
Contributor

@MatanBobi

I've put up a pull request to add @ph-fritsche! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants