@fluentui-react-native/focus-zone 0.9.16 → 0.9.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +16 -1
- package/CHANGELOG.md +10 -2
- package/macos/RCTFocusZone.m +23 -22
- package/package.json +1 -1
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,22 @@
|
|
|
2
2
|
"name": "@fluentui-react-native/focus-zone",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "
|
|
5
|
+
"date": "Tue, 12 Apr 2022 00:34:43 GMT",
|
|
6
|
+
"tag": "@fluentui-react-native/focus-zone_v0.9.17",
|
|
7
|
+
"version": "0.9.17",
|
|
8
|
+
"comments": {
|
|
9
|
+
"patch": [
|
|
10
|
+
{
|
|
11
|
+
"author": "sanajmi@microsoft.com",
|
|
12
|
+
"package": "@fluentui-react-native/focus-zone",
|
|
13
|
+
"commit": "832066543f281fdec866f738d36f7f73f6bbb4f7",
|
|
14
|
+
"comment": "Add support for nested focus zones"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"date": "Fri, 08 Apr 2022 18:53:11 GMT",
|
|
6
21
|
"tag": "@fluentui-react-native/focus-zone_v0.9.16",
|
|
7
22
|
"version": "0.9.16",
|
|
8
23
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
# Change Log - @fluentui-react-native/focus-zone
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Tue, 12 Apr 2022 00:34:43 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 0.9.17
|
|
8
|
+
|
|
9
|
+
Tue, 12 Apr 2022 00:34:43 GMT
|
|
10
|
+
|
|
11
|
+
### Patches
|
|
12
|
+
|
|
13
|
+
- Add support for nested focus zones (sanajmi@microsoft.com)
|
|
14
|
+
|
|
7
15
|
## 0.9.16
|
|
8
16
|
|
|
9
|
-
Fri, 08 Apr 2022 18:
|
|
17
|
+
Fri, 08 Apr 2022 18:53:11 GMT
|
|
10
18
|
|
|
11
19
|
### Patches
|
|
12
20
|
|
package/macos/RCTFocusZone.m
CHANGED
|
@@ -147,19 +147,22 @@ static inline BOOL IsHorizontalNavigationWithinZoneAction(FocusZoneAction action
|
|
|
147
147
|
return action == FocusZoneActionRightArrow || action == FocusZoneActionLeftArrow;
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
+
/// Returns the topmost view of the given view's superview heirarchy that is a FocusZone.
|
|
151
|
+
/// Returns nil if no FocusZone is found.
|
|
150
152
|
static RCTFocusZone *GetFocusZoneAncestor(NSView *view)
|
|
151
153
|
{
|
|
152
154
|
NSView *candidateView = view;
|
|
153
155
|
NSView *topLevelView = [[view window] contentView];
|
|
156
|
+
RCTFocusZone *focusZoneAncestor = nil;
|
|
154
157
|
while (candidateView != nil && candidateView != topLevelView)
|
|
155
158
|
{
|
|
156
159
|
if ([candidateView isKindOfClass:[RCTFocusZone class]])
|
|
157
160
|
{
|
|
158
|
-
|
|
161
|
+
focusZoneAncestor = (RCTFocusZone *)candidateView;
|
|
159
162
|
}
|
|
160
163
|
candidateView = [candidateView superview];
|
|
161
164
|
}
|
|
162
|
-
return
|
|
165
|
+
return focusZoneAncestor;
|
|
163
166
|
}
|
|
164
167
|
|
|
165
168
|
/// Bypass FocusZone if it's empty or has no focusable elements
|
|
@@ -362,34 +365,32 @@ static BOOL ShouldSkipFocusZone(NSView *view)
|
|
|
362
365
|
NSView *nextViewToFocus;
|
|
363
366
|
|
|
364
367
|
[[self window] recalculateKeyViewLoop];
|
|
368
|
+
|
|
369
|
+
// Find the first view outside the FocusZone (or any parent FocusZones) to place focus
|
|
370
|
+
RCTFocusZone *focusZoneAncestor = GetFocusZoneAncestor(self);
|
|
365
371
|
|
|
366
372
|
if (action == FocusZoneActionTab) // Advance to next zone
|
|
367
373
|
{
|
|
368
|
-
|
|
374
|
+
nextViewToFocus = [self nextValidKeyView];
|
|
375
|
+
while([nextViewToFocus isDescendantOf:focusZoneAncestor])
|
|
369
376
|
{
|
|
370
|
-
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
nextViewToFocus = [([self nextViewToFocusForCondition:block] ?: self) nextValidKeyView];
|
|
374
|
-
}
|
|
375
|
-
else // action == FocusZoneActionShiftTab per the conditional in keyDown
|
|
376
|
-
{
|
|
377
|
-
nextViewToFocus = [self previousValidKeyView];
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
if ([nextViewToFocus isDescendantOf:self])
|
|
381
|
-
{
|
|
382
|
-
nextViewToFocus = nil;
|
|
377
|
+
nextViewToFocus = [nextViewToFocus nextValidKeyView];
|
|
378
|
+
}
|
|
383
379
|
}
|
|
384
380
|
else if (action == FocusZoneActionShiftTab)
|
|
385
381
|
{
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
RCTFocusZone *nextFocusZone = GetFocusZoneAncestor(nextViewToFocus);
|
|
389
|
-
NSView *element = [nextFocusZone defaultKeyView];
|
|
390
|
-
if (element != nil)
|
|
382
|
+
nextViewToFocus = [self previousValidKeyView];
|
|
383
|
+
while([nextViewToFocus isDescendantOf:focusZoneAncestor])
|
|
391
384
|
{
|
|
392
|
-
nextViewToFocus =
|
|
385
|
+
nextViewToFocus = [nextViewToFocus previousValidKeyView];
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
// If the previous view is in a FocusZone, focus on its defaultKeyView
|
|
389
|
+
// (For FocusZoneActionTab, this is handled by becomeFirstResponder).
|
|
390
|
+
RCTFocusZone *focusZoneAncestor = GetFocusZoneAncestor(nextViewToFocus);
|
|
391
|
+
NSView *ancestorKeyView = [focusZoneAncestor defaultKeyView];
|
|
392
|
+
if (ancestorKeyView != nil) {
|
|
393
|
+
nextViewToFocus = [focusZoneAncestor defaultKeyView];
|
|
393
394
|
}
|
|
394
395
|
}
|
|
395
396
|
|
package/package.json
CHANGED