@fluentui-react-native/focus-zone 0.9.6 → 0.9.9

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 CHANGED
@@ -2,7 +2,52 @@
2
2
  "name": "@fluentui-react-native/focus-zone",
3
3
  "entries": [
4
4
  {
5
- "date": "Thu, 03 Mar 2022 20:18:16 GMT",
5
+ "date": "Fri, 11 Mar 2022 00:34:24 GMT",
6
+ "tag": "@fluentui-react-native/focus-zone_v0.9.9",
7
+ "version": "0.9.9",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "author": "sanajmi@microsoft.com",
12
+ "package": "@fluentui-react-native/focus-zone",
13
+ "commit": "489339a0f6ebd9a4687c1c84e9bf8d274d8806d5",
14
+ "comment": "ContextualMenu macOS: Focus on menu rather than first menu item"
15
+ }
16
+ ]
17
+ }
18
+ },
19
+ {
20
+ "date": "Mon, 07 Mar 2022 19:15:33 GMT",
21
+ "tag": "@fluentui-react-native/focus-zone_v0.9.8",
22
+ "version": "0.9.8",
23
+ "comments": {
24
+ "patch": [
25
+ {
26
+ "author": "beachball",
27
+ "package": "@fluentui-react-native/focus-zone",
28
+ "comment": "Bump @fluentui-react-native/interactive-hooks to v0.14.3",
29
+ "commit": "d437b204aa63de4c9d4dd2f58ccf541c388ddaee"
30
+ }
31
+ ]
32
+ }
33
+ },
34
+ {
35
+ "date": "Fri, 04 Mar 2022 23:43:10 GMT",
36
+ "tag": "@fluentui-react-native/focus-zone_v0.9.7",
37
+ "version": "0.9.7",
38
+ "comments": {
39
+ "patch": [
40
+ {
41
+ "author": "beachball",
42
+ "package": "@fluentui-react-native/focus-zone",
43
+ "comment": "Bump @fluentui-react-native/interactive-hooks to v0.14.2",
44
+ "commit": "051e390caabfc13c4e53f9812f0ec7c5b56094a2"
45
+ }
46
+ ]
47
+ }
48
+ },
49
+ {
50
+ "date": "Thu, 03 Mar 2022 20:20:09 GMT",
6
51
  "tag": "@fluentui-react-native/focus-zone_v0.9.6",
7
52
  "version": "0.9.6",
8
53
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,36 @@
1
1
  # Change Log - @fluentui-react-native/focus-zone
2
2
 
3
- This log was last generated on Thu, 03 Mar 2022 20:18:16 GMT and should not be manually modified.
3
+ This log was last generated on Fri, 11 Mar 2022 00:34:24 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 0.9.9
8
+
9
+ Fri, 11 Mar 2022 00:34:24 GMT
10
+
11
+ ### Patches
12
+
13
+ - ContextualMenu macOS: Focus on menu rather than first menu item (sanajmi@microsoft.com)
14
+
15
+ ## 0.9.8
16
+
17
+ Mon, 07 Mar 2022 19:15:33 GMT
18
+
19
+ ### Patches
20
+
21
+ - Bump @fluentui-react-native/interactive-hooks to v0.14.3
22
+
23
+ ## 0.9.7
24
+
25
+ Fri, 04 Mar 2022 23:43:10 GMT
26
+
27
+ ### Patches
28
+
29
+ - Bump @fluentui-react-native/interactive-hooks to v0.14.2
30
+
7
31
  ## 0.9.6
8
32
 
9
- Thu, 03 Mar 2022 20:18:16 GMT
33
+ Thu, 03 Mar 2022 20:20:09 GMT
10
34
 
11
35
  ### Patches
12
36
 
@@ -45,6 +45,8 @@ static inline CGFloat GetMinDistanceBetweenRectVerticesAndPoint(NSRect rect, NSP
45
45
  );
46
46
  }
47
47
 
48
+ /// Performs a depth first search looking for the first key view in a parent view's view heirarchy.
49
+ /// This function does not take into account the geometric position of the view.
48
50
  static NSView *GetFirstKeyViewWithin(NSView *parentView)
49
51
  {
50
52
  for (NSView *view in [parentView subviews]) {
@@ -60,6 +62,24 @@ static NSView *GetFirstKeyViewWithin(NSView *parentView)
60
62
  return nil;
61
63
  }
62
64
 
65
+ /// Performs a depth first search looking for the last key view in a parent view's view heirarchy.
66
+ /// We find the last view by simply reversing the order of the subview array.
67
+ /// This function does not take into account the geometric position of the view.
68
+ static NSView *GetLastKeyViewWithin(NSView *parentView)
69
+ {
70
+ for (NSView *view in [[parentView subviews] reverseObjectEnumerator]) {
71
+ if ([view canBecomeKeyView]) {
72
+ return view;
73
+ }
74
+
75
+ NSView *match = GetLastKeyViewWithin(view);
76
+ if (match) {
77
+ return match;
78
+ }
79
+ }
80
+ return nil;
81
+ }
82
+
63
83
  static NSView *GetFirstResponder(NSWindow *window)
64
84
  {
65
85
  NSResponder *responder = [window firstResponder];
@@ -283,6 +303,21 @@ static RCTFocusZone *GetFocusZoneAncestor(NSView *view)
283
303
 
284
304
  - (NSView *)nextViewToFocusWithFallback:(FocusZoneAction)action
285
305
  {
306
+
307
+ // Special case if we're currently focused on self
308
+ NSView *firstResponder = GetFirstResponder([self window]);
309
+ if (self == firstResponder)
310
+ {
311
+ if (action == FocusZoneActionDownArrow)
312
+ {
313
+ return GetFirstKeyViewWithin(self);
314
+ }
315
+ else if (action == FocusZoneActionUpArrow)
316
+ {
317
+ return GetLastKeyViewWithin(self);
318
+ }
319
+ }
320
+
286
321
  NSView *nextViewToFocus = [self nextViewToFocusForAction:action];
287
322
 
288
323
  if (nextViewToFocus == nil)
@@ -367,18 +402,14 @@ static RCTFocusZone *GetFocusZoneAncestor(NSView *view)
367
402
  && (action == FocusZoneActionUpArrow || action == FocusZoneActionDownArrow))
368
403
  || (focusZoneDirection == FocusZoneDirectionNone))
369
404
  {
370
- [super keyDown:event];
405
+ passthrough = YES;
371
406
  }
372
407
  else
373
408
  {
374
409
  viewToFocus = [self nextViewToFocusWithFallback:action];
375
410
  }
376
411
 
377
- if (passthrough)
378
- {
379
- [super keyDown:event];
380
- }
381
- else if (viewToFocus != nil)
412
+ if (!passthrough && viewToFocus != nil)
382
413
  {
383
414
  [[self window] makeFirstResponder:viewToFocus];
384
415
  }
@@ -398,4 +429,4 @@ static RCTFocusZone *GetFocusZoneAncestor(NSView *view)
398
429
  return @"NavigateStopAtEnds";
399
430
  }
400
431
 
401
- @end
432
+ @end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui-react-native/focus-zone",
3
- "version": "0.9.6",
3
+ "version": "0.9.9",
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.3.1",
26
- "@fluentui-react-native/interactive-hooks": ">=0.14.1 <1.0.0",
26
+ "@fluentui-react-native/interactive-hooks": ">=0.14.3 <1.0.0",
27
27
  "@uifabricshared/foundation-composable": ">=0.10.2 <1.0.0",
28
28
  "@uifabricshared/foundation-settings": ">=0.11.2 <1.0.0"
29
29
  },