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

Expose API for virtual views to LayoutSpecs #85

Closed
emilsjolander opened this issue Apr 12, 2017 · 0 comments
Closed

Expose API for virtual views to LayoutSpecs #85

emilsjolander opened this issue Apr 12, 2017 · 0 comments

Comments

@emilsjolander
Copy link
Contributor

We expose AccessibilityDelegate method callbacks in LayoutSpecs as event handlers. However, we're missing getAccessibilityNodeProvider. Proper implementations of node providers can be very stateful since they need to handle hover callbacks. In order to make this as stateless as possible and play nice with the framework, there are two possibilities:

  1. Do not expose the creation of the AccessibilityNodeInfoProviderCompat object directly, instead expose its API as event handlers.
  2. Leverage the fact that ComponentAccessibilityDelegate extends ExploreByTouchHelper and expose its virtual view related abstract methods as event handlers. This would also require that we make sure that the dispatchHoverEvent callback is extended to arbitrary views and not just ComponentHost

Regardless of which idea we choose, there are a couple of things to consider:

  1. We should default to returning null in getAccessibilityNodeProvider. Returning a non-null value changes how/whether certain accessibility events are routed to the right callbacks
  2. MountSpecs that implement virtual view hierarchies, require we return a special node provider. If no event handler for node provider is set on the LayoutSpec, we should respect the MountSpec's original behavior, otherwise, we should override it. See ComponentAccessibilityDelegate#onInitializeAccessibilityNodeInfo for an example.

Code pointers

https://github.com/facebook/litho/blob/master/litho-core/src/main/java/com/facebook/litho/ComponentAccessibilityDelegate.java#L62

Point of contact: @muraziz

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

No branches or pull requests

3 participants