From ee36c6f2003fa16ebfca7394ab86ea754d4c37ee Mon Sep 17 00:00:00 2001 From: Navneet Kambo <72474613+nakambo@users.noreply.github.com> Date: Fri, 26 Jul 2024 23:22:28 -0700 Subject: [PATCH] [Mac] [Focus Zone] Restore broken direction = none functionality (#3692) --- ...e-1e63be00-70e8-4c8d-88be-e75acdcdaf39.json | 7 +++++++ .../components/FocusZone/macos/RCTFocusZone.m | 18 +++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 change/@fluentui-react-native-focus-zone-1e63be00-70e8-4c8d-88be-e75acdcdaf39.json diff --git a/change/@fluentui-react-native-focus-zone-1e63be00-70e8-4c8d-88be-e75acdcdaf39.json b/change/@fluentui-react-native-focus-zone-1e63be00-70e8-4c8d-88be-e75acdcdaf39.json new file mode 100644 index 0000000000..93d6757ca6 --- /dev/null +++ b/change/@fluentui-react-native-focus-zone-1e63be00-70e8-4c8d-88be-e75acdcdaf39.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "[Mac] [Focus Zone] Restore broken direction = none functionality", + "packageName": "@fluentui-react-native/focus-zone", + "email": "nakambo@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/packages/components/FocusZone/macos/RCTFocusZone.m b/packages/components/FocusZone/macos/RCTFocusZone.m index 5e1b6224a3..45ec1c1382 100644 --- a/packages/components/FocusZone/macos/RCTFocusZone.m +++ b/packages/components/FocusZone/macos/RCTFocusZone.m @@ -538,10 +538,10 @@ static BOOL ShouldSkipFocusZone(NSView *view) BOOL forward = action != FocusZoneActionShiftTab; NSView *firstResponder = GetFirstResponder([self window]); - NSView *nextViewToFocus = action == forward ? [firstResponder nextValidKeyView] : [firstResponder previousValidKeyView]; + NSView *nextViewToFocus = forward ? [firstResponder nextValidKeyView] : [firstResponder previousValidKeyView]; if (nextViewToFocus == self) - nextViewToFocus = action == forward ? [nextViewToFocus nextValidKeyView] : [nextViewToFocus previousValidKeyView];; + nextViewToFocus = forward ? [nextViewToFocus nextValidKeyView] : [nextViewToFocus previousValidKeyView];; if ([@"Normal" isEqual:tabKeyNavigation] || [nextViewToFocus isDescendantOf:self]) return nextViewToFocus; @@ -573,11 +573,7 @@ static BOOL ShouldSkipFocusZone(NSView *view) BOOL passthrough = NO; NSView *viewToFocus = nil; - if ([self disabled] || action == FocusZoneActionNone - || (focusZoneDirection == FocusZoneDirectionVertical - && (action == FocusZoneActionRightArrow || action == FocusZoneActionLeftArrow)) - || (focusZoneDirection == FocusZoneDirectionHorizontal - && (action == FocusZoneActionUpArrow || action == FocusZoneActionDownArrow))) + if ([self disabled] || action == FocusZoneActionNone) { passthrough = YES; } @@ -585,6 +581,14 @@ static BOOL ShouldSkipFocusZone(NSView *view) { viewToFocus = [self nextViewToFocusForTab:action]; } + else if ((focusZoneDirection == FocusZoneDirectionVertical + && (action == FocusZoneActionRightArrow || action == FocusZoneActionLeftArrow)) + || (focusZoneDirection == FocusZoneDirectionHorizontal + && (action == FocusZoneActionUpArrow || action == FocusZoneActionDownArrow)) + || (focusZoneDirection == FocusZoneDirectionNone)) + { + passthrough = YES; + } else { viewToFocus = [self nextViewToFocusWithFallback:action considerCircular:[@"NavigateWrap" isEqual:navigateAtEnd]];