-
Notifications
You must be signed in to change notification settings - Fork 263
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
Why are accessibilty elements only text, textInput, and switch? #1566
Comments
To make a The elements types you mention: Not sure what happens in Tamagui, as the code is pretty abstract. If you think that RNTL is missing something, the create a minimal Expo app using Tamagui that showcases the missing case. Having something like this at hand would allow me verify whether to tweak our simulation code. |
Adding I created an example expo app, but my test using userEvent wasn't checking the component. I tried all kinds of selectors but that didn't make a difference. Out of desperation I tried using fireEvent and that worked. Could you take a look? My hunch (from my understanding) is that fireEvent checks the parents handlers until it finds one, and userEvent doesn't do that so here, the onValueChange is on the RadioGroup level, not the RadioGroupItem so userEvent can't trigger it. I'm not sure how to trigger it with userEvent since I need to click on the specific item. |
Just ran into this myself! I believe Tamagui should handle adding |
@KrastanD User Event has code code that performs lookup for pressable element from given element up:
From that point it locks on that element, and tries to send all of touch events there without further lookups. |
@KrastanD I've reviewed this issue to check if it can be closed as it looked stale. I've run your repro repository and found it interesting. When I run
Tamagui is quite complex as it uses some additional abstractions, so it's hard for me to say what exactly is happening there. The thing that I can see, is that the host element tree does not seem to contain any event handlers ( Let me know if you are willing to explore this more or should we close this issue. |
I am on the exact same situation, after hours of research I found that using the accesible attribute works fine and I'm thinking on adding a wrapper for all these elements from Tamagui that need it. I wasn't very happy but I think that's the only solution, then I found that only fireEvent works instead of user event. My concern is, can we rely on all these and be in peace with having the wrapper plus using fire event? It's messing with my head a little bit since I have the feeling that fireEvent will be away eventually, perhaps I'm wrong on that. Thanks |
@mfrfinbox you should raise this issue with Tamagui maintainers. Their code is pretty complex due to abstractions and RN/web shared code, so they should be the best people to consult on this. From my perspective the issue is on Tamagui's side (lack of |
For the accessible={true}, that should be contributed to tamagui directly imo so everyone gets it out the box and don't run into it like @mfrfinbox and I have. As for the host elements not showing onPress, I'm not quite sure how that happens. Aren't all composite elements built from host elements? The |
I've open the issues on the Tamagui side, thanks |
@mfrfinbox thank's for logging the issues, please update them with |
@KrastanD as for host elements, in React the components are not being extended (subclassed) in classic OOP way, they are being rendered (composed) by other (composite) components. The reason why User Events insist on invoking only events on the host components, is that these are the only components that the user can see as they correspond to UI controls in iOS/Android. Composite components are just an abstraction, and cannot be directly observed or interacted by the users. |
Done! |
Closing as it requires fixing upstream (Tamagui) |
Ask your Question
I am using Tamagui and I want to check that a radio button has been checked but it's not able to and I think it's because Tamagui adds the radio role to a view but React Native Testing Library only checks text, textInput and switch elements for a role.
Could you explain the reasoning for having only those elements as accessibility elements?
Do you have a recommended way that I can check that the radio button has been checked, or does Tamagui have to change how they set role?
The text was updated successfully, but these errors were encountered: