Open quantizor opened 1 year ago
I'm running into the same issue when using useId in my forms, any update on this?
I have similar issues with custom query that gets elements based on another element's aria-describedby
attributes. IDs in those fields are populated using React.useId()
.
As work-around I had to refactor the selector a bit:
const id = subject.attr('aria-describedby'); // e.g. ":r3:-error"
- return cy.get(`#${id}-error`); // Fails with "unrecognized expression: #:r3:-error"
+ return cy.get(`[id="${id}-error"]`); // Works, generates selector '[id=":r3:-error"]' which works fine
This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.
Current behavior
When trying to interact with an element rendered by React that has
htmlFor
set to an ID returned by theuseId()
hook, the peculiar syntax React uses for IDs in React 18 actually causes an error:Note the
:r0:
portion (I know it says react-aria but under the hood it's using R18'suseId
API).We don't want to escape
htmlFor
because that breaks platform functionality, jQuery should just handle/ignore it.Interestingly the selector used in Cypress didn't even target that attribute:
Desired behavior
No response
Test code to reproduce
Example React code:
Then example Cypress test code:
Cypress Version
12.17.4
Node version
20
Operating System
macOS latest
Debug Logs
No response
Other
No response