@fluentui-react-native/focus-zone 0.11.6 → 0.11.8
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 +37 -1
- package/CHANGELOG.md +19 -2
- package/jest.config.js +1 -1
- package/macos/RCTFocusZone.h +1 -1
- package/macos/RCTFocusZone.m +19 -19
- package/macos/RCTFocusZoneManager.m +2 -2
- package/package.json +2 -2
- package/src/__tests__/__snapshots__/FocusZone.test.tsx.snap +552 -552
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,43 @@
|
|
|
2
2
|
"name": "@fluentui-react-native/focus-zone",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "Wed,
|
|
5
|
+
"date": "Wed, 30 Nov 2022 21:32:24 GMT",
|
|
6
|
+
"tag": "@fluentui-react-native/focus-zone_v0.11.8",
|
|
7
|
+
"version": "0.11.8",
|
|
8
|
+
"comments": {
|
|
9
|
+
"patch": [
|
|
10
|
+
{
|
|
11
|
+
"author": "sanajmi@microsoft.com",
|
|
12
|
+
"package": "@fluentui-react-native/focus-zone",
|
|
13
|
+
"commit": "838377b70fc3574bf27571af721792b0a8787010",
|
|
14
|
+
"comment": "Update jest configs for ContextualMenu, FocusTrapZone, FocusZone"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"date": "Mon, 28 Nov 2022 11:51:05 GMT",
|
|
21
|
+
"tag": "@fluentui-react-native/focus-zone_v0.11.7",
|
|
22
|
+
"version": "0.11.7",
|
|
23
|
+
"comments": {
|
|
24
|
+
"patch": [
|
|
25
|
+
{
|
|
26
|
+
"author": "sanajmi@microsoft.com",
|
|
27
|
+
"package": "@fluentui-react-native/focus-zone",
|
|
28
|
+
"commit": "b8b9d8fb1285fb8037949a9aa75a333ed134b751",
|
|
29
|
+
"comment": "FocusZone (macOS): move focus between first responders instead of key views"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"author": "beachball",
|
|
33
|
+
"package": "@fluentui-react-native/focus-zone",
|
|
34
|
+
"comment": "Bump @fluentui-react-native/interactive-hooks to v0.21.2",
|
|
35
|
+
"commit": "890ff26064088ee92d44bb8730b8629143533451"
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"date": "Wed, 16 Nov 2022 08:47:25 GMT",
|
|
6
42
|
"tag": "@fluentui-react-native/focus-zone_v0.11.6",
|
|
7
43
|
"version": "0.11.6",
|
|
8
44
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,29 @@
|
|
|
1
1
|
# Change Log - @fluentui-react-native/focus-zone
|
|
2
2
|
|
|
3
|
-
This log was last generated on Wed,
|
|
3
|
+
This log was last generated on Wed, 30 Nov 2022 21:32:24 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 0.11.8
|
|
8
|
+
|
|
9
|
+
Wed, 30 Nov 2022 21:32:24 GMT
|
|
10
|
+
|
|
11
|
+
### Patches
|
|
12
|
+
|
|
13
|
+
- Update jest configs for ContextualMenu, FocusTrapZone, FocusZone (sanajmi@microsoft.com)
|
|
14
|
+
|
|
15
|
+
## 0.11.7
|
|
16
|
+
|
|
17
|
+
Mon, 28 Nov 2022 11:51:05 GMT
|
|
18
|
+
|
|
19
|
+
### Patches
|
|
20
|
+
|
|
21
|
+
- FocusZone (macOS): move focus between first responders instead of key views (sanajmi@microsoft.com)
|
|
22
|
+
- Bump @fluentui-react-native/interactive-hooks to v0.21.2
|
|
23
|
+
|
|
7
24
|
## 0.11.6
|
|
8
25
|
|
|
9
|
-
Wed, 16 Nov 2022 08:
|
|
26
|
+
Wed, 16 Nov 2022 08:47:25 GMT
|
|
10
27
|
|
|
11
28
|
### Patches
|
|
12
29
|
|
package/jest.config.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
const { configureReactNativeJest } = require('@fluentui-react-native/scripts');
|
|
2
|
-
module.exports = configureReactNativeJest('
|
|
2
|
+
module.exports = configureReactNativeJest('win32');
|
package/macos/RCTFocusZone.h
CHANGED
|
@@ -15,6 +15,6 @@ typedef NS_ENUM(NSInteger, FocusZoneDirection) {
|
|
|
15
15
|
@property(nonatomic) BOOL disabled;
|
|
16
16
|
@property(nonatomic) FocusZoneDirection focusZoneDirection;
|
|
17
17
|
@property(nonatomic) NSString *navigateAtEnd;
|
|
18
|
-
@property(nonatomic) NSView *
|
|
18
|
+
@property(nonatomic) NSView *defaultResponder;
|
|
19
19
|
|
|
20
20
|
@end
|
package/macos/RCTFocusZone.m
CHANGED
|
@@ -33,7 +33,7 @@ static inline CGFloat GetDistanceBetweenRects(NSRect rect1, NSRect rect2)
|
|
|
33
33
|
|
|
34
34
|
CGFloat rect1Offset = isRTL ? rect1.size.width : 0;
|
|
35
35
|
CGFloat rect2Offset = isRTL ? rect2.size.width : 0;
|
|
36
|
-
|
|
36
|
+
|
|
37
37
|
NSPoint rect1Corner = NSMakePoint(rect1.origin.x + rect1Offset , rect1.origin.y);
|
|
38
38
|
NSPoint rect2Corner = NSMakePoint(rect2.origin.x + rect2Offset , rect2.origin.y);
|
|
39
39
|
|
|
@@ -50,9 +50,9 @@ static inline CGFloat GetMinDistanceBetweenRectVerticesAndPoint(NSRect rect, NSP
|
|
|
50
50
|
);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
/// Performs a depth first search looking for the first
|
|
53
|
+
/// Performs a depth first search looking for the first view that accepts responder status in a parent view's view hierarchy.
|
|
54
54
|
/// This function does not take into account the geometric position of the view.
|
|
55
|
-
static NSView *
|
|
55
|
+
static NSView *GetFirstFocusableViewWithin(NSView *parentView)
|
|
56
56
|
{
|
|
57
57
|
if ([[parentView subviews] count] < 1)
|
|
58
58
|
{
|
|
@@ -60,11 +60,11 @@ static NSView *GetFirstKeyViewWithin(NSView *parentView)
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
for (NSView *view in [parentView subviews]) {
|
|
63
|
-
if ([view
|
|
63
|
+
if ([view acceptsFirstResponder]) {
|
|
64
64
|
return view;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
NSView *match =
|
|
67
|
+
NSView *match = GetFirstFocusableViewWithin(view);
|
|
68
68
|
if (match) {
|
|
69
69
|
return match;
|
|
70
70
|
}
|
|
@@ -72,17 +72,17 @@ static NSView *GetFirstKeyViewWithin(NSView *parentView)
|
|
|
72
72
|
return nil;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
/// Performs a depth first search looking for the last
|
|
75
|
+
/// Performs a depth first search looking for the last that accepts responder status in a parent view's view hierarchy.
|
|
76
76
|
/// We find the last view by simply reversing the order of the subview array.
|
|
77
77
|
/// This function does not take into account the geometric position of the view.
|
|
78
|
-
static NSView *
|
|
78
|
+
static NSView *GetLastFocusableViewWithin(NSView *parentView)
|
|
79
79
|
{
|
|
80
80
|
for (NSView *view in [[parentView subviews] reverseObjectEnumerator]) {
|
|
81
|
-
if ([view
|
|
81
|
+
if ([view acceptsFirstResponder]) {
|
|
82
82
|
return view;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
NSView *match =
|
|
85
|
+
NSView *match = GetLastFocusableViewWithin(view);
|
|
86
86
|
if (match) {
|
|
87
87
|
return match;
|
|
88
88
|
}
|
|
@@ -175,7 +175,7 @@ static BOOL ShouldSkipFocusZone(NSView *view)
|
|
|
175
175
|
{
|
|
176
176
|
if([view isKindOfClass:[RCTFocusZone class]])
|
|
177
177
|
{
|
|
178
|
-
NSView *keyView =
|
|
178
|
+
NSView *keyView = GetFirstFocusableViewWithin(view);
|
|
179
179
|
// FocusZone is empty or has no focusable elements
|
|
180
180
|
if (keyView == nil)
|
|
181
181
|
{
|
|
@@ -195,7 +195,7 @@ static BOOL ShouldSkipFocusZone(NSView *view)
|
|
|
195
195
|
|
|
196
196
|
- (BOOL)becomeFirstResponder
|
|
197
197
|
{
|
|
198
|
-
NSView *keyView =
|
|
198
|
+
NSView *keyView = _defaultResponder ?: GetFirstFocusableViewWithin(self);
|
|
199
199
|
return !_disabled && [[self window] makeFirstResponder:keyView];
|
|
200
200
|
}
|
|
201
201
|
|
|
@@ -210,7 +210,7 @@ static BOOL ShouldSkipFocusZone(NSView *view)
|
|
|
210
210
|
NSView *candidateView = [queue firstObject];
|
|
211
211
|
[queue removeObjectAtIndex:0];
|
|
212
212
|
|
|
213
|
-
if ([candidateView isNotEqualTo:self] && [candidateView
|
|
213
|
+
if ([candidateView isNotEqualTo:self] && [candidateView acceptsFirstResponder] && isLeadingCandidate(candidateView))
|
|
214
214
|
{
|
|
215
215
|
nextViewToFocus = candidateView;
|
|
216
216
|
}
|
|
@@ -281,7 +281,7 @@ static BOOL ShouldSkipFocusZone(NSView *view)
|
|
|
281
281
|
if (!skip)
|
|
282
282
|
{
|
|
283
283
|
CGFloat distance = GetDistanceBetweenRects(firstResponderRect, candidateRect);
|
|
284
|
-
|
|
284
|
+
|
|
285
285
|
// If there are other candidate views inside the same ScrollView as the firstResponder,
|
|
286
286
|
// prefer those views over other views outside the scrollview, even if they are closer.
|
|
287
287
|
if ([firstResponderEnclosingScrollView isEqualTo:[candidateView enclosingScrollView]])
|
|
@@ -356,11 +356,11 @@ static BOOL ShouldSkipFocusZone(NSView *view)
|
|
|
356
356
|
{
|
|
357
357
|
if (action == FocusZoneActionDownArrow)
|
|
358
358
|
{
|
|
359
|
-
return
|
|
359
|
+
return GetFirstFocusableViewWithin(self);
|
|
360
360
|
}
|
|
361
361
|
else if (action == FocusZoneActionUpArrow)
|
|
362
362
|
{
|
|
363
|
-
return
|
|
363
|
+
return GetLastFocusableViewWithin(self);
|
|
364
364
|
}
|
|
365
365
|
}
|
|
366
366
|
|
|
@@ -387,7 +387,7 @@ static BOOL ShouldSkipFocusZone(NSView *view)
|
|
|
387
387
|
NSView *nextViewToFocus;
|
|
388
388
|
|
|
389
389
|
[[self window] recalculateKeyViewLoop];
|
|
390
|
-
|
|
390
|
+
|
|
391
391
|
// Find the first view outside the FocusZone (or any parent FocusZones) to place focus
|
|
392
392
|
RCTFocusZone *focusZoneAncestor = GetFocusZoneAncestor(self);
|
|
393
393
|
|
|
@@ -418,13 +418,13 @@ static BOOL ShouldSkipFocusZone(NSView *view)
|
|
|
418
418
|
}
|
|
419
419
|
nextViewToFocus = [nextViewToFocus previousValidKeyView];
|
|
420
420
|
}
|
|
421
|
-
|
|
421
|
+
|
|
422
422
|
// If the previous view is in a FocusZone, focus on its defaultKeyView
|
|
423
423
|
// (For FocusZoneActionTab, this is handled by becomeFirstResponder).
|
|
424
424
|
RCTFocusZone *focusZoneAncestor = GetFocusZoneAncestor(nextViewToFocus);
|
|
425
|
-
NSView *ancestorKeyView = [focusZoneAncestor
|
|
425
|
+
NSView *ancestorKeyView = [focusZoneAncestor defaultResponder];
|
|
426
426
|
if (ancestorKeyView != nil) {
|
|
427
|
-
nextViewToFocus = [focusZoneAncestor
|
|
427
|
+
nextViewToFocus = [focusZoneAncestor defaultResponder];
|
|
428
428
|
}
|
|
429
429
|
}
|
|
430
430
|
|
|
@@ -39,8 +39,8 @@ RCT_CUSTOM_VIEW_PROPERTY(defaultTabbableElement, NSNumber, RCTFocusZone)
|
|
|
39
39
|
{
|
|
40
40
|
NSNumber *tag = [RCTConvert NSNumber:json];
|
|
41
41
|
RCTUIManager *manager = [[self bridge] uiManager];
|
|
42
|
-
NSView *
|
|
43
|
-
[view
|
|
42
|
+
NSView *defaultResponder = [manager viewForReactTag:tag];
|
|
43
|
+
[view setDefaultResponder:defaultResponder];
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
- (RCTView *)view
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluentui-react-native/focus-zone",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.8",
|
|
4
4
|
"description": "A cross-platform FocusZone component using the Fluent Design System",
|
|
5
5
|
"main": "lib-commonjs/index.js",
|
|
6
6
|
"module": "lib/index.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@fluentui-react-native/component-cache": "^1.4.2",
|
|
26
|
-
"@fluentui-react-native/interactive-hooks": ">=0.21.
|
|
26
|
+
"@fluentui-react-native/interactive-hooks": ">=0.21.2 <1.0.0",
|
|
27
27
|
"@uifabricshared/foundation-composable": ">=0.11.1 <1.0.0",
|
|
28
28
|
"@uifabricshared/foundation-settings": ">=0.12.1 <1.0.0"
|
|
29
29
|
},
|