-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
feat(ControlWindows): Adds control component for tab stops #1411
Conversation
@rigdern the benefit of this approach is that it won't require overriding |
ControlWindows is a UserControl with a single child Canvas. It has props to enable tab stop, tab index, keyboard navigation mode, and keyUp/Down events. Fixes microsoft#886
Codecov Report
@@ Coverage Diff @@
## master #1411 +/- ##
==========================================
- Coverage 31.78% 31.36% -0.43%
==========================================
Files 259 262 +3
Lines 19249 19511 +262
Branches 1623 1633 +10
==========================================
Hits 6119 6119
- Misses 12976 13238 +262
Partials 154 154
Continue to review full report at Codecov.
|
private void OnKeyUp(object sender, KeyEventArgs e) | ||
#endif | ||
{ | ||
if (sender == e.OriginalSource) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a good heuristic. Even though this is a bubbling event in JavaScript, there is no concept of Handled
/ Unhandled
, so parent components will not get onKey[Up|Down]
events that a JavaScript component does not want to handle. One example of where this will probably be needed is in implementing tab and arrow key accessibility for ListView. The individual list items will likely be focusable and may have responders for Space
and Enter
, but they will want the arrow key events to bubble to the ListView
parent so they can change the focus programmatically (unless arrow keys work by default for tab stop controls in the same parent).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's see if we can learn something about how to design this from touch events. I believe React Native only listens for touch events on the RootView. Do you understand the rationale behind this design?
Also, it seems like touch events would have a similar problem regarding the Handled
property. How do touch events deal with Handled
and would that solution work for keyboard events as well?
Focus and blur seem similar to touch, keyboard, and mouse events. Many views can generate these kinds of events and views that generate these events can be nested inside of other views that generate these events. What are other examples of events like this and which ones listen at the RootView only vs have a listener per view?
In reply to: 143015754 [](ancestors = 143015754)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rigdern I believe touch events are sufficiently different from the focus stack and keyboard events. When I first started thinking about how to implement this, I thought we might want to do something similar to the touch responder architecture in React.js and simulate the focus stack entirely in JS. This would be a lot of work, and ultimately will always be riddled with bugs where behaviors are inconsistent with what's expected in native platform.
Currently, we don't deal with the Handled
property on touch events because the events need to bubble to the root view. The only components that handle touch events are built-in gesture responders like ScrollViewer, FlipView, etc., and that's all handled via direct manipulation (not the UI thread touch events).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe touch events are sufficiently different from the focus stack and keyboard events.
Can you elaborate on how they're sufficiently different?
When I first started thinking about how to implement this, I thought we might want to do something similar to the touch responder architecture in React.js and simulate the focus stack entirely in JS. This would be a lot of work
Can you elaborate on why it's a lot of work? For focus, wouldn't we just tell React Native to dispatch the event into the JavaScript engine to the view with the appropriate tag? And then React Native would take care of the bubbling and capture phases.
Currently, we don't deal with the Handled property on touch events because the events need to bubble to the root view.
Does that mean if we listen to events on the RootView, we don't have to worry about the Handled
property? An exception I could see is if we wanted to mark Handled
to true
immediately on the control that triggered the event to prevent one of its native ancestors from handling the event in an undesirable way.
In ReactXP, Is Let's briefly summarize our options:
In reply to: 334535799 [](ancestors = 334535799) |
👍 we can override the
In terms of the options -
In reply to: 334611994 [](ancestors = 334611994,334535799) |
@rozele I think this PR is now obsolete. |
Thanks @reseul! Closing. |
ControlWindows is a UserControl with a single child Canvas. It has props to enable tab stop, tab index, keyboard navigation mode, and keyUp/Down events.
cc @rigdern
Fixes #886