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

<Text.Detail> Missing id forwarding results in a difficulty for testing field components #2867

Closed
ragafus opened this issue Jul 25, 2024 · 2 comments · Fixed by #2866
Closed
Labels
💅 Type: Enhancement Improves existing code

Comments

@ragafus
Copy link
Contributor

ragafus commented Jul 25, 2024

Describe the bug
Field components forward an internal id called sequentialErrorsId to the FieldErrors component. FieldErrors component forwards this id to ErrorMessage component. ErrorMessage components forwards this id to Text.Detail. And Text.Detail components does NOT always forward this id to the underlying element.

This missing id results in difficulties when testing a form field: with testing library, it becomes difficult to identify which element contains the error message. So, test cases where error messages are checked need of boilerplate code.

To Reproduce
Steps to reproduce the behavior:

  1. Go to any app that renders ui-kit field components
  2. Make one form field be in an error state.
  3. Inspect the DOM

Expected behavior
I expect the sequentialErrorsId to be forwarded to the underlying element to easily identify the error message when testing.
expect(field).toHaveErrorMessage("whatever")

Screenshots
Screenshot 2024-07-25 at 14 08 56
Screenshot 2024-07-25 at 14 09 15

@ragafus
Copy link
Contributor Author

ragafus commented Jul 25, 2024

I've created an initial PR #2866
Feel free to close it at any time if stale

@ddouglasz
Copy link
Contributor

Thank you for reporting this. We will review the PR and update you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💅 Type: Enhancement Improves existing code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants