Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { View, ScrollView, Pressable } from 'react-native';
import { View, ScrollView, Pressable, TextInput } from 'react-native';

import type { FocusZoneDirection, FocusZoneTabNavigation } from '@fluentui/react-native';
import { FocusZone, MenuButton, Text, useOnPressWithFocus } from '@fluentui/react-native';
Expand DownExpand Up@@ -207,6 +207,19 @@ const FocusZoneGrid: React.FunctionComponent = () => {
);
};

const FocusZoneTextInput: React.FunctionComponent = () => {
return (
<FocusZoneListWrapper>
<>
<Text>FocusZone Grid</Text>
<FocusZone>
<TextInput multiline={true} />
</FocusZone>
</>
</FocusZoneListWrapper>
);
};

const focusZoneSections: TestSection[] = [
{
name: 'Common FocusZone Usage',
Expand DownExpand Up@@ -245,6 +258,10 @@ const focusZoneSections: TestSection[] = [
name: 'FocusZone Grid',
component: FocusZoneGrid,
},
{
name: 'FocusZone with TextInput',
component: FocusZoneTextInput,
},
];

const e2eSections: TestSection[] = [
Expand Down
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Fix TextInput focus when inside a FocusZone",
"packageName": "@fluentui-react-native/focus-zone",
"email": "nakambo@microsoft.com",
"dependentChangeType": "patch"
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Add TextInput inside FocusZone case",
"packageName": "@fluentui-react-native/tester",
"email": "nakambo@microsoft.com",
"dependentChangeType": "patch"
}
10 changes: 9 additions & 1 deletion packages/components/FocusZone/macos/RCTFocusZone.m
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
#import "KeyCodes.h"
#import <React/RCTBaseTextInputView.h>
#import "RCTFocusZone.h"
#import "RCTi18nUtil.h"

Expand DownExpand Up@@ -61,7 +62,14 @@ static inline CGFloat GetMinDistanceBetweenRectVerticesAndPoint(NSRect rect, NSP

for (NSView *view in [parentView subviews]) {
if ([view acceptsFirstResponder]) {
return view;
if ([view isKindOfClass:[RCTBaseTextInputView class]]) {
RCTUIView *backedTextInputView = [(RCTBaseTextInputView *)view backedTextInputView];
if ([backedTextInputView acceptsFirstResponder]) {
return backedTextInputView;
}
} else {
return view;
}
}

NSView *match = GetFirstFocusableViewWithin(view);
Expand Down